Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-tsserver / node_modules / typescript / lib / tsc.js
1 /*! *****************************************************************************
2 Copyright (c) Microsoft Corporation. All rights reserved.
3 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4 this file except in compliance with the License. You may obtain a copy of the
5 License at http://www.apache.org/licenses/LICENSE-2.0
6
7 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10 MERCHANTABLITY OR NON-INFRINGEMENT.
11
12 See the Apache Version 2.0 License for specific language governing permissions
13 and limitations under the License.
14 ***************************************************************************** */
15
16
17 "use strict";
18 var __spreadArrays = (this && this.__spreadArrays) || function () {
19     for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
20     for (var r = Array(s), k = 0, i = 0; i < il; i++)
21         for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
22             r[k] = a[j];
23     return r;
24 };
25 var __assign = (this && this.__assign) || function () {
26     __assign = Object.assign || function(t) {
27         for (var s, i = 1, n = arguments.length; i < n; i++) {
28             s = arguments[i];
29             for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
30                 t[p] = s[p];
31         }
32         return t;
33     };
34     return __assign.apply(this, arguments);
35 };
36 var __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.2";
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 getPropertyOfType(getTypeOfSymbol(resolved), name.escapedText);
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                 while (true) {
52616                     var flags = flow.flags;
52617                     if (flags & 4096) {
52618                         for (var i = sharedFlowStart; i < sharedFlowCount; i++) {
52619                             if (sharedFlowNodes[i] === flow) {
52620                                 flowDepth--;
52621                                 return sharedFlowTypes[i];
52622                             }
52623                         }
52624                     }
52625                     var type = void 0;
52626                     if (flags & 16) {
52627                         type = getTypeAtFlowAssignment(flow);
52628                         if (!type) {
52629                             flow = flow.antecedent;
52630                             continue;
52631                         }
52632                     }
52633                     else if (flags & 512) {
52634                         type = getTypeAtFlowCall(flow);
52635                         if (!type) {
52636                             flow = flow.antecedent;
52637                             continue;
52638                         }
52639                     }
52640                     else if (flags & 96) {
52641                         type = getTypeAtFlowCondition(flow);
52642                     }
52643                     else if (flags & 128) {
52644                         type = getTypeAtSwitchClause(flow);
52645                     }
52646                     else if (flags & 12) {
52647                         if (flow.antecedents.length === 1) {
52648                             flow = flow.antecedents[0];
52649                             continue;
52650                         }
52651                         type = flags & 4 ?
52652                             getTypeAtFlowBranchLabel(flow) :
52653                             getTypeAtFlowLoopLabel(flow);
52654                     }
52655                     else if (flags & 256) {
52656                         type = getTypeAtFlowArrayMutation(flow);
52657                         if (!type) {
52658                             flow = flow.antecedent;
52659                             continue;
52660                         }
52661                     }
52662                     else if (flags & 1024) {
52663                         var target = flow.target;
52664                         var saveAntecedents = target.antecedents;
52665                         target.antecedents = flow.antecedents;
52666                         type = getTypeAtFlowNode(flow.antecedent);
52667                         target.antecedents = saveAntecedents;
52668                     }
52669                     else if (flags & 2) {
52670                         var container = flow.node;
52671                         if (container && container !== flowContainer &&
52672                             reference.kind !== 201 &&
52673                             reference.kind !== 202 &&
52674                             reference.kind !== 107) {
52675                             flow = container.flowNode;
52676                             continue;
52677                         }
52678                         type = initialType;
52679                     }
52680                     else {
52681                         type = convertAutoToAny(declaredType);
52682                     }
52683                     if (flags & 4096) {
52684                         sharedFlowNodes[sharedFlowCount] = flow;
52685                         sharedFlowTypes[sharedFlowCount] = type;
52686                         sharedFlowCount++;
52687                     }
52688                     flowDepth--;
52689                     return type;
52690                 }
52691             }
52692             function getInitialOrAssignedType(flow) {
52693                 var node = flow.node;
52694                 return getConstraintForLocation(node.kind === 249 || node.kind === 198 ?
52695                     getInitialType(node) :
52696                     getAssignedType(node), reference);
52697             }
52698             function getTypeAtFlowAssignment(flow) {
52699                 var node = flow.node;
52700                 if (isMatchingReference(reference, node)) {
52701                     if (!isReachableFlowNode(flow)) {
52702                         return unreachableNeverType;
52703                     }
52704                     if (ts.getAssignmentTargetKind(node) === 2) {
52705                         var flowType = getTypeAtFlowNode(flow.antecedent);
52706                         return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType));
52707                     }
52708                     if (declaredType === autoType || declaredType === autoArrayType) {
52709                         if (isEmptyArrayAssignment(node)) {
52710                             return getEvolvingArrayType(neverType);
52711                         }
52712                         var assignedType = getWidenedLiteralType(getInitialOrAssignedType(flow));
52713                         return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType;
52714                     }
52715                     if (declaredType.flags & 1048576) {
52716                         return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow));
52717                     }
52718                     return declaredType;
52719                 }
52720                 if (containsMatchingReference(reference, node)) {
52721                     if (!isReachableFlowNode(flow)) {
52722                         return unreachableNeverType;
52723                     }
52724                     if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) {
52725                         var init = ts.getDeclaredExpandoInitializer(node);
52726                         if (init && (init.kind === 208 || init.kind === 209)) {
52727                             return getTypeAtFlowNode(flow.antecedent);
52728                         }
52729                     }
52730                     return declaredType;
52731                 }
52732                 if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 238 && isMatchingReference(reference, node.parent.parent.expression)) {
52733                     return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent)));
52734                 }
52735                 return undefined;
52736             }
52737             function narrowTypeByAssertion(type, expr) {
52738                 var node = ts.skipParentheses(expr);
52739                 if (node.kind === 94) {
52740                     return unreachableNeverType;
52741                 }
52742                 if (node.kind === 216) {
52743                     if (node.operatorToken.kind === 55) {
52744                         return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right);
52745                     }
52746                     if (node.operatorToken.kind === 56) {
52747                         return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]);
52748                     }
52749                 }
52750                 return narrowType(type, node, true);
52751             }
52752             function getTypeAtFlowCall(flow) {
52753                 var signature = getEffectsSignature(flow.node);
52754                 if (signature) {
52755                     var predicate = getTypePredicateOfSignature(signature);
52756                     if (predicate && (predicate.kind === 2 || predicate.kind === 3)) {
52757                         var flowType = getTypeAtFlowNode(flow.antecedent);
52758                         var type = finalizeEvolvingArrayType(getTypeFromFlowType(flowType));
52759                         var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, true) :
52760                             predicate.kind === 3 && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) :
52761                                 type;
52762                         return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType));
52763                     }
52764                     if (getReturnTypeOfSignature(signature).flags & 131072) {
52765                         return unreachableNeverType;
52766                     }
52767                 }
52768                 return undefined;
52769             }
52770             function getTypeAtFlowArrayMutation(flow) {
52771                 if (declaredType === autoType || declaredType === autoArrayType) {
52772                     var node = flow.node;
52773                     var expr = node.kind === 203 ?
52774                         node.expression.expression :
52775                         node.left.expression;
52776                     if (isMatchingReference(reference, getReferenceCandidate(expr))) {
52777                         var flowType = getTypeAtFlowNode(flow.antecedent);
52778                         var type = getTypeFromFlowType(flowType);
52779                         if (ts.getObjectFlags(type) & 256) {
52780                             var evolvedType_1 = type;
52781                             if (node.kind === 203) {
52782                                 for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) {
52783                                     var arg = _a[_i];
52784                                     evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg);
52785                                 }
52786                             }
52787                             else {
52788                                 var indexType = getContextFreeTypeOfExpression(node.left.argumentExpression);
52789                                 if (isTypeAssignableToKind(indexType, 296)) {
52790                                     evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right);
52791                                 }
52792                             }
52793                             return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType));
52794                         }
52795                         return flowType;
52796                     }
52797                 }
52798                 return undefined;
52799             }
52800             function getTypeAtFlowCondition(flow) {
52801                 var flowType = getTypeAtFlowNode(flow.antecedent);
52802                 var type = getTypeFromFlowType(flowType);
52803                 if (type.flags & 131072) {
52804                     return flowType;
52805                 }
52806                 var assumeTrue = (flow.flags & 32) !== 0;
52807                 var nonEvolvingType = finalizeEvolvingArrayType(type);
52808                 var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue);
52809                 if (narrowedType === nonEvolvingType) {
52810                     return flowType;
52811                 }
52812                 return createFlowType(narrowedType, isIncomplete(flowType));
52813             }
52814             function getTypeAtSwitchClause(flow) {
52815                 var expr = flow.switchStatement.expression;
52816                 var flowType = getTypeAtFlowNode(flow.antecedent);
52817                 var type = getTypeFromFlowType(flowType);
52818                 if (isMatchingReference(reference, expr)) {
52819                     type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
52820                 }
52821                 else if (expr.kind === 211 && isMatchingReference(reference, expr.expression)) {
52822                     type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
52823                 }
52824                 else {
52825                     if (strictNullChecks) {
52826                         if (optionalChainContainsReference(expr, reference)) {
52827                             type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 | 131072)); });
52828                         }
52829                         else if (expr.kind === 211 && optionalChainContainsReference(expr.expression, reference)) {
52830                             type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 || t.flags & 128 && t.value === "undefined"); });
52831                         }
52832                     }
52833                     if (isMatchingReferenceDiscriminant(expr, type)) {
52834                         type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); });
52835                     }
52836                 }
52837                 return createFlowType(type, isIncomplete(flowType));
52838             }
52839             function getTypeAtFlowBranchLabel(flow) {
52840                 var antecedentTypes = [];
52841                 var subtypeReduction = false;
52842                 var seenIncomplete = false;
52843                 var bypassFlow;
52844                 for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) {
52845                     var antecedent = _a[_i];
52846                     if (!bypassFlow && antecedent.flags & 128 && antecedent.clauseStart === antecedent.clauseEnd) {
52847                         bypassFlow = antecedent;
52848                         continue;
52849                     }
52850                     var flowType = getTypeAtFlowNode(antecedent);
52851                     var type = getTypeFromFlowType(flowType);
52852                     if (type === declaredType && declaredType === initialType) {
52853                         return type;
52854                     }
52855                     ts.pushIfUnique(antecedentTypes, type);
52856                     if (!isTypeSubsetOf(type, declaredType)) {
52857                         subtypeReduction = true;
52858                     }
52859                     if (isIncomplete(flowType)) {
52860                         seenIncomplete = true;
52861                     }
52862                 }
52863                 if (bypassFlow) {
52864                     var flowType = getTypeAtFlowNode(bypassFlow);
52865                     var type = getTypeFromFlowType(flowType);
52866                     if (!ts.contains(antecedentTypes, type) && !isExhaustiveSwitchStatement(bypassFlow.switchStatement)) {
52867                         if (type === declaredType && declaredType === initialType) {
52868                             return type;
52869                         }
52870                         antecedentTypes.push(type);
52871                         if (!isTypeSubsetOf(type, declaredType)) {
52872                             subtypeReduction = true;
52873                         }
52874                         if (isIncomplete(flowType)) {
52875                             seenIncomplete = true;
52876                         }
52877                     }
52878                 }
52879                 return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 : 1), seenIncomplete);
52880             }
52881             function getTypeAtFlowLoopLabel(flow) {
52882                 var id = getFlowNodeId(flow);
52883                 var cache = flowLoopCaches[id] || (flowLoopCaches[id] = new ts.Map());
52884                 var key = getOrSetCacheKey();
52885                 if (!key) {
52886                     return declaredType;
52887                 }
52888                 var cached = cache.get(key);
52889                 if (cached) {
52890                     return cached;
52891                 }
52892                 for (var i = flowLoopStart; i < flowLoopCount; i++) {
52893                     if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) {
52894                         return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1), true);
52895                     }
52896                 }
52897                 var antecedentTypes = [];
52898                 var subtypeReduction = false;
52899                 var firstAntecedentType;
52900                 for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) {
52901                     var antecedent = _a[_i];
52902                     var flowType = void 0;
52903                     if (!firstAntecedentType) {
52904                         flowType = firstAntecedentType = getTypeAtFlowNode(antecedent);
52905                     }
52906                     else {
52907                         flowLoopNodes[flowLoopCount] = flow;
52908                         flowLoopKeys[flowLoopCount] = key;
52909                         flowLoopTypes[flowLoopCount] = antecedentTypes;
52910                         flowLoopCount++;
52911                         var saveFlowTypeCache = flowTypeCache;
52912                         flowTypeCache = undefined;
52913                         flowType = getTypeAtFlowNode(antecedent);
52914                         flowTypeCache = saveFlowTypeCache;
52915                         flowLoopCount--;
52916                         var cached_1 = cache.get(key);
52917                         if (cached_1) {
52918                             return cached_1;
52919                         }
52920                     }
52921                     var type = getTypeFromFlowType(flowType);
52922                     ts.pushIfUnique(antecedentTypes, type);
52923                     if (!isTypeSubsetOf(type, declaredType)) {
52924                         subtypeReduction = true;
52925                     }
52926                     if (type === declaredType) {
52927                         break;
52928                     }
52929                 }
52930                 var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 : 1);
52931                 if (isIncomplete(firstAntecedentType)) {
52932                     return createFlowType(result, true);
52933                 }
52934                 cache.set(key, result);
52935                 return result;
52936             }
52937             function isMatchingReferenceDiscriminant(expr, computedType) {
52938                 var type = declaredType.flags & 1048576 ? declaredType : computedType;
52939                 if (!(type.flags & 1048576) || !ts.isAccessExpression(expr)) {
52940                     return false;
52941                 }
52942                 var name = getAccessedPropertyName(expr);
52943                 if (name === undefined) {
52944                     return false;
52945                 }
52946                 return isMatchingReference(reference, expr.expression) && isDiscriminantProperty(type, name);
52947             }
52948             function narrowTypeByDiscriminant(type, access, narrowType) {
52949                 var propName = getAccessedPropertyName(access);
52950                 if (propName === undefined) {
52951                     return type;
52952                 }
52953                 var propType = getTypeOfPropertyOfType(type, propName);
52954                 if (!propType) {
52955                     return type;
52956                 }
52957                 var narrowedPropType = narrowType(propType);
52958                 return filterType(type, function (t) {
52959                     var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName);
52960                     return !(discriminantType.flags & 131072) && isTypeComparableTo(discriminantType, narrowedPropType);
52961                 });
52962             }
52963             function narrowTypeByTruthiness(type, expr, assumeTrue) {
52964                 if (isMatchingReference(reference, expr)) {
52965                     return getTypeWithFacts(type, assumeTrue ? 4194304 : 8388608);
52966                 }
52967                 if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) {
52968                     type = getTypeWithFacts(type, 2097152);
52969                 }
52970                 if (isMatchingReferenceDiscriminant(expr, type)) {
52971                     return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 : 8388608); });
52972                 }
52973                 return type;
52974             }
52975             function isTypePresencePossible(type, propName, assumeTrue) {
52976                 if (getIndexInfoOfType(type, 0)) {
52977                     return true;
52978                 }
52979                 var prop = getPropertyOfType(type, propName);
52980                 if (prop) {
52981                     return prop.flags & 16777216 ? true : assumeTrue;
52982                 }
52983                 return !assumeTrue;
52984             }
52985             function narrowByInKeyword(type, literal, assumeTrue) {
52986                 if (type.flags & (1048576 | 524288)
52987                     || isThisTypeParameter(type)
52988                     || type.flags & 2097152 && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) {
52989                     var propName_1 = ts.escapeLeadingUnderscores(literal.text);
52990                     return filterType(type, function (t) { return isTypePresencePossible(t, propName_1, assumeTrue); });
52991                 }
52992                 return type;
52993             }
52994             function narrowTypeByBinaryExpression(type, expr, assumeTrue) {
52995                 switch (expr.operatorToken.kind) {
52996                     case 62:
52997                     case 74:
52998                     case 75:
52999                     case 76:
53000                         return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue);
53001                     case 34:
53002                     case 35:
53003                     case 36:
53004                     case 37:
53005                         var operator_1 = expr.operatorToken.kind;
53006                         var left_1 = getReferenceCandidate(expr.left);
53007                         var right_1 = getReferenceCandidate(expr.right);
53008                         if (left_1.kind === 211 && ts.isStringLiteralLike(right_1)) {
53009                             return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue);
53010                         }
53011                         if (right_1.kind === 211 && ts.isStringLiteralLike(left_1)) {
53012                             return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue);
53013                         }
53014                         if (isMatchingReference(reference, left_1)) {
53015                             return narrowTypeByEquality(type, operator_1, right_1, assumeTrue);
53016                         }
53017                         if (isMatchingReference(reference, right_1)) {
53018                             return narrowTypeByEquality(type, operator_1, left_1, assumeTrue);
53019                         }
53020                         if (strictNullChecks) {
53021                             if (optionalChainContainsReference(left_1, reference)) {
53022                                 type = narrowTypeByOptionalChainContainment(type, operator_1, right_1, assumeTrue);
53023                             }
53024                             else if (optionalChainContainsReference(right_1, reference)) {
53025                                 type = narrowTypeByOptionalChainContainment(type, operator_1, left_1, assumeTrue);
53026                             }
53027                         }
53028                         if (isMatchingReferenceDiscriminant(left_1, type)) {
53029                             return narrowTypeByDiscriminant(type, left_1, function (t) { return narrowTypeByEquality(t, operator_1, right_1, assumeTrue); });
53030                         }
53031                         if (isMatchingReferenceDiscriminant(right_1, type)) {
53032                             return narrowTypeByDiscriminant(type, right_1, function (t) { return narrowTypeByEquality(t, operator_1, left_1, assumeTrue); });
53033                         }
53034                         if (isMatchingConstructorReference(left_1)) {
53035                             return narrowTypeByConstructor(type, operator_1, right_1, assumeTrue);
53036                         }
53037                         if (isMatchingConstructorReference(right_1)) {
53038                             return narrowTypeByConstructor(type, operator_1, left_1, assumeTrue);
53039                         }
53040                         break;
53041                     case 101:
53042                         return narrowTypeByInstanceof(type, expr, assumeTrue);
53043                     case 100:
53044                         var target = getReferenceCandidate(expr.right);
53045                         if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) {
53046                             return narrowByInKeyword(type, expr.left, assumeTrue);
53047                         }
53048                         break;
53049                     case 27:
53050                         return narrowType(type, expr.right, assumeTrue);
53051                 }
53052                 return type;
53053             }
53054             function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) {
53055                 var equalsOperator = operator === 34 || operator === 36;
53056                 var nullableFlags = operator === 34 || operator === 35 ? 98304 : 32768;
53057                 var valueType = getTypeOfExpression(value);
53058                 var removeNullable = equalsOperator !== assumeTrue && everyType(valueType, function (t) { return !!(t.flags & nullableFlags); }) ||
53059                     equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 | nullableFlags)); });
53060                 return removeNullable ? getTypeWithFacts(type, 2097152) : type;
53061             }
53062             function narrowTypeByEquality(type, operator, value, assumeTrue) {
53063                 if (type.flags & 1) {
53064                     return type;
53065                 }
53066                 if (operator === 35 || operator === 37) {
53067                     assumeTrue = !assumeTrue;
53068                 }
53069                 var valueType = getTypeOfExpression(value);
53070                 if ((type.flags & 2) && assumeTrue && (operator === 36 || operator === 37)) {
53071                     if (valueType.flags & (131068 | 67108864)) {
53072                         return valueType;
53073                     }
53074                     if (valueType.flags & 524288) {
53075                         return nonPrimitiveType;
53076                     }
53077                     return type;
53078                 }
53079                 if (valueType.flags & 98304) {
53080                     if (!strictNullChecks) {
53081                         return type;
53082                     }
53083                     var doubleEquals = operator === 34 || operator === 35;
53084                     var facts = doubleEquals ?
53085                         assumeTrue ? 262144 : 2097152 :
53086                         valueType.flags & 65536 ?
53087                             assumeTrue ? 131072 : 1048576 :
53088                             assumeTrue ? 65536 : 524288;
53089                     return getTypeWithFacts(type, facts);
53090                 }
53091                 if (assumeTrue) {
53092                     var filterFn = operator === 34 ?
53093                         (function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); }) :
53094                         function (t) { return areTypesComparable(t, valueType); };
53095                     return replacePrimitivesWithLiterals(filterType(type, filterFn), valueType);
53096                 }
53097                 if (isUnitType(valueType)) {
53098                     var regularType_1 = getRegularTypeOfLiteralType(valueType);
53099                     return filterType(type, function (t) { return isUnitType(t) ? !areTypesComparable(t, valueType) : getRegularTypeOfLiteralType(t) !== regularType_1; });
53100                 }
53101                 return type;
53102             }
53103             function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) {
53104                 if (operator === 35 || operator === 37) {
53105                     assumeTrue = !assumeTrue;
53106                 }
53107                 var target = getReferenceCandidate(typeOfExpr.expression);
53108                 if (!isMatchingReference(reference, target)) {
53109                     if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) {
53110                         return getTypeWithFacts(type, 2097152);
53111                     }
53112                     return type;
53113                 }
53114                 if (type.flags & 1 && literal.text === "function") {
53115                     return type;
53116                 }
53117                 if (assumeTrue && type.flags & 2 && literal.text === "object") {
53118                     if (typeOfExpr.parent.parent.kind === 216) {
53119                         var expr = typeOfExpr.parent.parent;
53120                         if (expr.operatorToken.kind === 55 && expr.right === typeOfExpr.parent && containsTruthyCheck(reference, expr.left)) {
53121                             return nonPrimitiveType;
53122                         }
53123                     }
53124                     return getUnionType([nonPrimitiveType, nullType]);
53125                 }
53126                 var facts = assumeTrue ?
53127                     typeofEQFacts.get(literal.text) || 128 :
53128                     typeofNEFacts.get(literal.text) || 32768;
53129                 var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text);
53130                 return getTypeWithFacts(assumeTrue && impliedType ? mapType(type, narrowUnionMemberByTypeof(impliedType)) : type, facts);
53131             }
53132             function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
53133                 var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
53134                 return everyClauseChecks ? getTypeWithFacts(type, 2097152) : type;
53135             }
53136             function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) {
53137                 var switchTypes = getSwitchClauseTypes(switchStatement);
53138                 if (!switchTypes.length) {
53139                     return type;
53140                 }
53141                 var clauseTypes = switchTypes.slice(clauseStart, clauseEnd);
53142                 var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType);
53143                 if ((type.flags & 2) && !hasDefaultClause) {
53144                     var groundClauseTypes = void 0;
53145                     for (var i = 0; i < clauseTypes.length; i += 1) {
53146                         var t = clauseTypes[i];
53147                         if (t.flags & (131068 | 67108864)) {
53148                             if (groundClauseTypes !== undefined) {
53149                                 groundClauseTypes.push(t);
53150                             }
53151                         }
53152                         else if (t.flags & 524288) {
53153                             if (groundClauseTypes === undefined) {
53154                                 groundClauseTypes = clauseTypes.slice(0, i);
53155                             }
53156                             groundClauseTypes.push(nonPrimitiveType);
53157                         }
53158                         else {
53159                             return type;
53160                         }
53161                     }
53162                     return getUnionType(groundClauseTypes === undefined ? clauseTypes : groundClauseTypes);
53163                 }
53164                 var discriminantType = getUnionType(clauseTypes);
53165                 var caseType = discriminantType.flags & 131072 ? neverType :
53166                     replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType);
53167                 if (!hasDefaultClause) {
53168                     return caseType;
53169                 }
53170                 var defaultType = filterType(type, function (t) { return !(isUnitType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(t))); });
53171                 return caseType.flags & 131072 ? defaultType : getUnionType([caseType, defaultType]);
53172             }
53173             function getImpliedTypeFromTypeofGuard(type, text) {
53174                 switch (text) {
53175                     case "function":
53176                         return type.flags & 1 ? type : globalFunctionType;
53177                     case "object":
53178                         return type.flags & 2 ? getUnionType([nonPrimitiveType, nullType]) : type;
53179                     default:
53180                         return typeofTypesByName.get(text);
53181                 }
53182             }
53183             function narrowUnionMemberByTypeof(candidate) {
53184                 return function (type) {
53185                     if (isTypeSubtypeOf(type, candidate)) {
53186                         return type;
53187                     }
53188                     if (isTypeSubtypeOf(candidate, type)) {
53189                         return candidate;
53190                     }
53191                     if (type.flags & 465829888) {
53192                         var constraint = getBaseConstraintOfType(type) || anyType;
53193                         if (isTypeSubtypeOf(candidate, constraint)) {
53194                             return getIntersectionType([type, candidate]);
53195                         }
53196                     }
53197                     return type;
53198                 };
53199             }
53200             function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
53201                 var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, true);
53202                 if (!switchWitnesses.length) {
53203                     return type;
53204                 }
53205                 var defaultCaseLocation = ts.findIndex(switchWitnesses, function (elem) { return elem === undefined; });
53206                 var hasDefaultClause = clauseStart === clauseEnd || (defaultCaseLocation >= clauseStart && defaultCaseLocation < clauseEnd);
53207                 var clauseWitnesses;
53208                 var switchFacts;
53209                 if (defaultCaseLocation > -1) {
53210                     var witnesses = switchWitnesses.filter(function (witness) { return witness !== undefined; });
53211                     var fixedClauseStart = defaultCaseLocation < clauseStart ? clauseStart - 1 : clauseStart;
53212                     var fixedClauseEnd = defaultCaseLocation < clauseEnd ? clauseEnd - 1 : clauseEnd;
53213                     clauseWitnesses = witnesses.slice(fixedClauseStart, fixedClauseEnd);
53214                     switchFacts = getFactsFromTypeofSwitch(fixedClauseStart, fixedClauseEnd, witnesses, hasDefaultClause);
53215                 }
53216                 else {
53217                     clauseWitnesses = switchWitnesses.slice(clauseStart, clauseEnd);
53218                     switchFacts = getFactsFromTypeofSwitch(clauseStart, clauseEnd, switchWitnesses, hasDefaultClause);
53219                 }
53220                 if (hasDefaultClause) {
53221                     return filterType(type, function (t) { return (getTypeFacts(t) & switchFacts) === switchFacts; });
53222                 }
53223                 var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofGuard(type, text) || type; })), switchFacts);
53224                 return getTypeWithFacts(mapType(type, narrowUnionMemberByTypeof(impliedType)), switchFacts);
53225             }
53226             function isMatchingConstructorReference(expr) {
53227                 return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
53228                     ts.isElementAccessExpression(expr) && ts.isStringLiteralLike(expr.argumentExpression) && expr.argumentExpression.text === "constructor") &&
53229                     isMatchingReference(reference, expr.expression);
53230             }
53231             function narrowTypeByConstructor(type, operator, identifier, assumeTrue) {
53232                 if (assumeTrue ? (operator !== 34 && operator !== 36) : (operator !== 35 && operator !== 37)) {
53233                     return type;
53234                 }
53235                 var identifierType = getTypeOfExpression(identifier);
53236                 if (!isFunctionType(identifierType) && !isConstructorType(identifierType)) {
53237                     return type;
53238                 }
53239                 var prototypeProperty = getPropertyOfType(identifierType, "prototype");
53240                 if (!prototypeProperty) {
53241                     return type;
53242                 }
53243                 var prototypeType = getTypeOfSymbol(prototypeProperty);
53244                 var candidate = !isTypeAny(prototypeType) ? prototypeType : undefined;
53245                 if (!candidate || candidate === globalObjectType || candidate === globalFunctionType) {
53246                     return type;
53247                 }
53248                 if (isTypeAny(type)) {
53249                     return candidate;
53250                 }
53251                 return filterType(type, function (t) { return isConstructedBy(t, candidate); });
53252                 function isConstructedBy(source, target) {
53253                     if (source.flags & 524288 && ts.getObjectFlags(source) & 1 ||
53254                         target.flags & 524288 && ts.getObjectFlags(target) & 1) {
53255                         return source.symbol === target.symbol;
53256                     }
53257                     return isTypeSubtypeOf(source, target);
53258                 }
53259             }
53260             function narrowTypeByInstanceof(type, expr, assumeTrue) {
53261                 var left = getReferenceCandidate(expr.left);
53262                 if (!isMatchingReference(reference, left)) {
53263                     if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) {
53264                         return getTypeWithFacts(type, 2097152);
53265                     }
53266                     return type;
53267                 }
53268                 var rightType = getTypeOfExpression(expr.right);
53269                 if (!isTypeDerivedFrom(rightType, globalFunctionType)) {
53270                     return type;
53271                 }
53272                 var targetType;
53273                 var prototypeProperty = getPropertyOfType(rightType, "prototype");
53274                 if (prototypeProperty) {
53275                     var prototypePropertyType = getTypeOfSymbol(prototypeProperty);
53276                     if (!isTypeAny(prototypePropertyType)) {
53277                         targetType = prototypePropertyType;
53278                     }
53279                 }
53280                 if (isTypeAny(type) && (targetType === globalObjectType || targetType === globalFunctionType)) {
53281                     return type;
53282                 }
53283                 if (!targetType) {
53284                     var constructSignatures = getSignaturesOfType(rightType, 1);
53285                     targetType = constructSignatures.length ?
53286                         getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })) :
53287                         emptyObjectType;
53288                 }
53289                 if (!assumeTrue && rightType.flags & 1048576) {
53290                     var nonConstructorTypeInUnion = ts.find(rightType.types, function (t) { return !isConstructorType(t); });
53291                     if (!nonConstructorTypeInUnion)
53292                         return type;
53293                 }
53294                 return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom);
53295             }
53296             function getNarrowedType(type, candidate, assumeTrue, isRelated) {
53297                 if (!assumeTrue) {
53298                     return filterType(type, function (t) { return !isRelated(t, candidate); });
53299                 }
53300                 if (type.flags & 1048576) {
53301                     var assignableType = filterType(type, function (t) { return isRelated(t, candidate); });
53302                     if (!(assignableType.flags & 131072)) {
53303                         return assignableType;
53304                     }
53305                 }
53306                 return isTypeSubtypeOf(candidate, type) ? candidate : isTypeSubtypeOf(type, candidate) ? type : getIntersectionType([type, candidate]);
53307             }
53308             function narrowTypeByCallExpression(type, callExpression, assumeTrue) {
53309                 if (hasMatchingArgument(callExpression, reference)) {
53310                     var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined;
53311                     var predicate = signature && getTypePredicateOfSignature(signature);
53312                     if (predicate && (predicate.kind === 0 || predicate.kind === 1)) {
53313                         return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue);
53314                     }
53315                 }
53316                 return type;
53317             }
53318             function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) {
53319                 if (predicate.type && !(isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType))) {
53320                     var predicateArgument = getTypePredicateArgument(predicate, callExpression);
53321                     if (predicateArgument) {
53322                         if (isMatchingReference(reference, predicateArgument)) {
53323                             return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf);
53324                         }
53325                         if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) &&
53326                             !(getTypeFacts(predicate.type) & 65536)) {
53327                             type = getTypeWithFacts(type, 2097152);
53328                         }
53329                         if (isMatchingReferenceDiscriminant(predicateArgument, type)) {
53330                             return narrowTypeByDiscriminant(type, predicateArgument, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, isTypeSubtypeOf); });
53331                         }
53332                     }
53333                 }
53334                 return type;
53335             }
53336             function narrowType(type, expr, assumeTrue) {
53337                 if (ts.isExpressionOfOptionalChainRoot(expr) ||
53338                     ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 && expr.parent.left === expr) {
53339                     return narrowTypeByOptionality(type, expr, assumeTrue);
53340                 }
53341                 switch (expr.kind) {
53342                     case 78:
53343                     case 107:
53344                     case 105:
53345                     case 201:
53346                     case 202:
53347                         return narrowTypeByTruthiness(type, expr, assumeTrue);
53348                     case 203:
53349                         return narrowTypeByCallExpression(type, expr, assumeTrue);
53350                     case 207:
53351                     case 225:
53352                         return narrowType(type, expr.expression, assumeTrue);
53353                     case 216:
53354                         return narrowTypeByBinaryExpression(type, expr, assumeTrue);
53355                     case 214:
53356                         if (expr.operator === 53) {
53357                             return narrowType(type, expr.operand, !assumeTrue);
53358                         }
53359                         break;
53360                 }
53361                 return type;
53362             }
53363             function narrowTypeByOptionality(type, expr, assumePresent) {
53364                 if (isMatchingReference(reference, expr)) {
53365                     return getTypeWithFacts(type, assumePresent ? 2097152 : 262144);
53366                 }
53367                 if (isMatchingReferenceDiscriminant(expr, type)) {
53368                     return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 : 262144); });
53369                 }
53370                 return type;
53371             }
53372         }
53373         function getTypeOfSymbolAtLocation(symbol, location) {
53374             symbol = symbol.exportSymbol || symbol;
53375             if (location.kind === 78) {
53376                 if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) {
53377                     location = location.parent;
53378                 }
53379                 if (ts.isExpressionNode(location) && !ts.isAssignmentTarget(location)) {
53380                     var type = getTypeOfExpression(location);
53381                     if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) {
53382                         return type;
53383                     }
53384                 }
53385             }
53386             return getTypeOfSymbol(symbol);
53387         }
53388         function getControlFlowContainer(node) {
53389             return ts.findAncestor(node.parent, function (node) {
53390                 return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) ||
53391                     node.kind === 257 ||
53392                     node.kind === 297 ||
53393                     node.kind === 163;
53394             });
53395         }
53396         function isParameterAssigned(symbol) {
53397             var func = ts.getRootDeclaration(symbol.valueDeclaration).parent;
53398             var links = getNodeLinks(func);
53399             if (!(links.flags & 8388608)) {
53400                 links.flags |= 8388608;
53401                 if (!hasParentWithAssignmentsMarked(func)) {
53402                     markParameterAssignments(func);
53403                 }
53404             }
53405             return symbol.isAssigned || false;
53406         }
53407         function hasParentWithAssignmentsMarked(node) {
53408             return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608); });
53409         }
53410         function markParameterAssignments(node) {
53411             if (node.kind === 78) {
53412                 if (ts.isAssignmentTarget(node)) {
53413                     var symbol = getResolvedSymbol(node);
53414                     if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 160) {
53415                         symbol.isAssigned = true;
53416                     }
53417                 }
53418             }
53419             else {
53420                 ts.forEachChild(node, markParameterAssignments);
53421             }
53422         }
53423         function isConstVariable(symbol) {
53424             return symbol.flags & 3 && (getDeclarationNodeFlagsFromSymbol(symbol) & 2) !== 0 && getTypeOfSymbol(symbol) !== autoArrayType;
53425         }
53426         function removeOptionalityFromDeclaredType(declaredType, declaration) {
53427             if (pushTypeResolution(declaration.symbol, 2)) {
53428                 var annotationIncludesUndefined = strictNullChecks &&
53429                     declaration.kind === 160 &&
53430                     declaration.initializer &&
53431                     getFalsyFlags(declaredType) & 32768 &&
53432                     !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768);
53433                 popTypeResolution();
53434                 return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288) : declaredType;
53435             }
53436             else {
53437                 reportCircularityError(declaration.symbol);
53438                 return declaredType;
53439             }
53440         }
53441         function isConstraintPosition(node) {
53442             var parent = node.parent;
53443             return parent.kind === 201 ||
53444                 parent.kind === 203 && parent.expression === node ||
53445                 parent.kind === 202 && parent.expression === node ||
53446                 parent.kind === 198 && parent.name === node && !!parent.initializer;
53447         }
53448         function typeHasNullableConstraint(type) {
53449             return type.flags & 58982400 && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304);
53450         }
53451         function getConstraintForLocation(type, node) {
53452             if (type && isConstraintPosition(node) && forEachType(type, typeHasNullableConstraint)) {
53453                 return mapType(getWidenedType(type), getBaseConstraintOrType);
53454             }
53455             return type;
53456         }
53457         function isExportOrExportExpression(location) {
53458             return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); });
53459         }
53460         function markAliasReferenced(symbol, location) {
53461             if (isNonLocalAlias(symbol, 111551) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) {
53462                 if (compilerOptions.preserveConstEnums && isExportOrExportExpression(location) || !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) {
53463                     markAliasSymbolAsReferenced(symbol);
53464                 }
53465                 else {
53466                     markConstEnumAliasAsReferenced(symbol);
53467                 }
53468             }
53469         }
53470         function checkIdentifier(node) {
53471             var symbol = getResolvedSymbol(node);
53472             if (symbol === unknownSymbol) {
53473                 return errorType;
53474             }
53475             if (symbol === argumentsSymbol) {
53476                 var container = ts.getContainingFunction(node);
53477                 if (languageVersion < 2) {
53478                     if (container.kind === 209) {
53479                         error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression);
53480                     }
53481                     else if (ts.hasSyntacticModifier(container, 256)) {
53482                         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);
53483                     }
53484                 }
53485                 getNodeLinks(container).flags |= 8192;
53486                 return getTypeOfSymbol(symbol);
53487             }
53488             if (!(node.parent && ts.isPropertyAccessExpression(node.parent) && node.parent.expression === node)) {
53489                 markAliasReferenced(symbol, node);
53490             }
53491             var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
53492             var sourceSymbol = localOrExportSymbol.flags & 2097152 ? resolveAlias(localOrExportSymbol) : localOrExportSymbol;
53493             if (getDeclarationNodeFlagsFromSymbol(sourceSymbol) & 134217728 && isUncalledFunctionReference(node.parent, sourceSymbol)) {
53494                 errorOrSuggestion(false, node, ts.Diagnostics._0_is_deprecated, node.escapedText);
53495             }
53496             var declaration = localOrExportSymbol.valueDeclaration;
53497             if (localOrExportSymbol.flags & 32) {
53498                 if (declaration.kind === 252
53499                     && ts.nodeIsDecorated(declaration)) {
53500                     var container = ts.getContainingClass(node);
53501                     while (container !== undefined) {
53502                         if (container === declaration && container.name !== node) {
53503                             getNodeLinks(declaration).flags |= 16777216;
53504                             getNodeLinks(node).flags |= 33554432;
53505                             break;
53506                         }
53507                         container = ts.getContainingClass(container);
53508                     }
53509                 }
53510                 else if (declaration.kind === 221) {
53511                     var container = ts.getThisContainer(node, false);
53512                     while (container.kind !== 297) {
53513                         if (container.parent === declaration) {
53514                             if (container.kind === 163 && ts.hasSyntacticModifier(container, 32)) {
53515                                 getNodeLinks(declaration).flags |= 16777216;
53516                                 getNodeLinks(node).flags |= 33554432;
53517                             }
53518                             break;
53519                         }
53520                         container = ts.getThisContainer(container, false);
53521                     }
53522                 }
53523             }
53524             checkNestedBlockScopedBinding(node, symbol);
53525             var type = getConstraintForLocation(getTypeOfSymbol(localOrExportSymbol), node);
53526             var assignmentKind = ts.getAssignmentTargetKind(node);
53527             if (assignmentKind) {
53528                 if (!(localOrExportSymbol.flags & 3) &&
53529                     !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512)) {
53530                     error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable, symbolToString(symbol));
53531                     return errorType;
53532                 }
53533                 if (isReadonlySymbol(localOrExportSymbol)) {
53534                     if (localOrExportSymbol.flags & 3) {
53535                         error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant, symbolToString(symbol));
53536                     }
53537                     else {
53538                         error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(symbol));
53539                     }
53540                     return errorType;
53541                 }
53542             }
53543             var isAlias = localOrExportSymbol.flags & 2097152;
53544             if (localOrExportSymbol.flags & 3) {
53545                 if (assignmentKind === 1) {
53546                     return type;
53547                 }
53548             }
53549             else if (isAlias) {
53550                 declaration = ts.find(symbol.declarations, isSomeImportDeclaration);
53551             }
53552             else {
53553                 return type;
53554             }
53555             if (!declaration) {
53556                 return type;
53557             }
53558             var isParameter = ts.getRootDeclaration(declaration).kind === 160;
53559             var declarationContainer = getControlFlowContainer(declaration);
53560             var flowContainer = getControlFlowContainer(node);
53561             var isOuterVariable = flowContainer !== declarationContainer;
53562             var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent);
53563             var isModuleExports = symbol.flags & 134217728;
53564             while (flowContainer !== declarationContainer && (flowContainer.kind === 208 ||
53565                 flowContainer.kind === 209 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) &&
53566                 (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) {
53567                 flowContainer = getControlFlowContainer(flowContainer);
53568             }
53569             var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) ||
53570                 type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 | 16384)) !== 0 ||
53571                     isInTypeQuery(node) || node.parent.kind === 270) ||
53572                 node.parent.kind === 225 ||
53573                 declaration.kind === 249 && declaration.exclamationToken ||
53574                 declaration.flags & 8388608;
53575             var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) :
53576                 type === autoType || type === autoArrayType ? undefinedType :
53577                     getOptionalType(type);
53578             var flowType = getFlowTypeOfReference(node, type, initialType, flowContainer, !assumeInitialized);
53579             if (!isEvolvingArrayOperationTarget(node) && (type === autoType || type === autoArrayType)) {
53580                 if (flowType === autoType || flowType === autoArrayType) {
53581                     if (noImplicitAny) {
53582                         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));
53583                         error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType));
53584                     }
53585                     return convertAutoToAny(flowType);
53586                 }
53587             }
53588             else if (!assumeInitialized && !(getFalsyFlags(type) & 32768) && getFalsyFlags(flowType) & 32768) {
53589                 error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol));
53590                 return type;
53591             }
53592             return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
53593         }
53594         function isInsideFunction(node, threshold) {
53595             return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n); });
53596         }
53597         function getPartOfForStatementContainingNode(node, container) {
53598             return ts.findAncestor(node, function (n) { return n === container ? "quit" : n === container.initializer || n === container.condition || n === container.incrementor || n === container.statement; });
53599         }
53600         function checkNestedBlockScopedBinding(node, symbol) {
53601             if (languageVersion >= 2 ||
53602                 (symbol.flags & (2 | 32)) === 0 ||
53603                 ts.isSourceFile(symbol.valueDeclaration) ||
53604                 symbol.valueDeclaration.parent.kind === 287) {
53605                 return;
53606             }
53607             var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration);
53608             var usedInFunction = isInsideFunction(node.parent, container);
53609             var current = container;
53610             var containedInIterationStatement = false;
53611             while (current && !ts.nodeStartsNewLexicalEnvironment(current)) {
53612                 if (ts.isIterationStatement(current, false)) {
53613                     containedInIterationStatement = true;
53614                     break;
53615                 }
53616                 current = current.parent;
53617             }
53618             if (containedInIterationStatement) {
53619                 if (usedInFunction) {
53620                     var capturesBlockScopeBindingInLoopBody = true;
53621                     if (ts.isForStatement(container)) {
53622                         var varDeclList = ts.getAncestor(symbol.valueDeclaration, 250);
53623                         if (varDeclList && varDeclList.parent === container) {
53624                             var part = getPartOfForStatementContainingNode(node.parent, container);
53625                             if (part) {
53626                                 var links = getNodeLinks(part);
53627                                 links.flags |= 131072;
53628                                 var capturedBindings = links.capturedBlockScopeBindings || (links.capturedBlockScopeBindings = []);
53629                                 ts.pushIfUnique(capturedBindings, symbol);
53630                                 if (part === container.initializer) {
53631                                     capturesBlockScopeBindingInLoopBody = false;
53632                                 }
53633                             }
53634                         }
53635                     }
53636                     if (capturesBlockScopeBindingInLoopBody) {
53637                         getNodeLinks(current).flags |= 65536;
53638                     }
53639                 }
53640                 if (ts.isForStatement(container)) {
53641                     var varDeclList = ts.getAncestor(symbol.valueDeclaration, 250);
53642                     if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) {
53643                         getNodeLinks(symbol.valueDeclaration).flags |= 4194304;
53644                     }
53645                 }
53646                 getNodeLinks(symbol.valueDeclaration).flags |= 524288;
53647             }
53648             if (usedInFunction) {
53649                 getNodeLinks(symbol.valueDeclaration).flags |= 262144;
53650             }
53651         }
53652         function isBindingCapturedByNode(node, decl) {
53653             var links = getNodeLinks(node);
53654             return !!links && ts.contains(links.capturedBlockScopeBindings, getSymbolOfNode(decl));
53655         }
53656         function isAssignedInBodyOfForStatement(node, container) {
53657             var current = node;
53658             while (current.parent.kind === 207) {
53659                 current = current.parent;
53660             }
53661             var isAssigned = false;
53662             if (ts.isAssignmentTarget(current)) {
53663                 isAssigned = true;
53664             }
53665             else if ((current.parent.kind === 214 || current.parent.kind === 215)) {
53666                 var expr = current.parent;
53667                 isAssigned = expr.operator === 45 || expr.operator === 46;
53668             }
53669             if (!isAssigned) {
53670                 return false;
53671             }
53672             return !!ts.findAncestor(current, function (n) { return n === container ? "quit" : n === container.statement; });
53673         }
53674         function captureLexicalThis(node, container) {
53675             getNodeLinks(node).flags |= 2;
53676             if (container.kind === 163 || container.kind === 166) {
53677                 var classNode = container.parent;
53678                 getNodeLinks(classNode).flags |= 4;
53679             }
53680             else {
53681                 getNodeLinks(container).flags |= 4;
53682             }
53683         }
53684         function findFirstSuperCall(node) {
53685             return ts.isSuperCall(node) ? node :
53686                 ts.isFunctionLike(node) ? undefined :
53687                     ts.forEachChild(node, findFirstSuperCall);
53688         }
53689         function classDeclarationExtendsNull(classDecl) {
53690             var classSymbol = getSymbolOfNode(classDecl);
53691             var classInstanceType = getDeclaredTypeOfSymbol(classSymbol);
53692             var baseConstructorType = getBaseConstructorTypeOfClass(classInstanceType);
53693             return baseConstructorType === nullWideningType;
53694         }
53695         function checkThisBeforeSuper(node, container, diagnosticMessage) {
53696             var containingClassDecl = container.parent;
53697             var baseTypeNode = ts.getClassExtendsHeritageElement(containingClassDecl);
53698             if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) {
53699                 if (node.flowNode && !isPostSuperFlowNode(node.flowNode, false)) {
53700                     error(node, diagnosticMessage);
53701                 }
53702             }
53703         }
53704         function checkThisExpression(node) {
53705             var container = ts.getThisContainer(node, true);
53706             var capturedByArrowFunction = false;
53707             if (container.kind === 166) {
53708                 checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class);
53709             }
53710             if (container.kind === 209) {
53711                 container = ts.getThisContainer(container, false);
53712                 capturedByArrowFunction = true;
53713             }
53714             switch (container.kind) {
53715                 case 256:
53716                     error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body);
53717                     break;
53718                 case 255:
53719                     error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location);
53720                     break;
53721                 case 166:
53722                     if (isInConstructorArgumentInitializer(node, container)) {
53723                         error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments);
53724                     }
53725                     break;
53726                 case 163:
53727                 case 162:
53728                     if (ts.hasSyntacticModifier(container, 32) && !(compilerOptions.target === 99 && compilerOptions.useDefineForClassFields)) {
53729                         error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer);
53730                     }
53731                     break;
53732                 case 158:
53733                     error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name);
53734                     break;
53735             }
53736             if (capturedByArrowFunction && languageVersion < 2) {
53737                 captureLexicalThis(node, container);
53738             }
53739             var type = tryGetThisTypeAt(node, true, container);
53740             if (noImplicitThis) {
53741                 var globalThisType_1 = getTypeOfSymbol(globalThisSymbol);
53742                 if (type === globalThisType_1 && capturedByArrowFunction) {
53743                     error(node, ts.Diagnostics.The_containing_arrow_function_captures_the_global_value_of_this);
53744                 }
53745                 else if (!type) {
53746                     var diag = error(node, ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation);
53747                     if (!ts.isSourceFile(container)) {
53748                         var outsideThis = tryGetThisTypeAt(container);
53749                         if (outsideThis && outsideThis !== globalThisType_1) {
53750                             ts.addRelatedInfo(diag, ts.createDiagnosticForNode(container, ts.Diagnostics.An_outer_value_of_this_is_shadowed_by_this_container));
53751                         }
53752                     }
53753                 }
53754             }
53755             return type || anyType;
53756         }
53757         function tryGetThisTypeAt(node, includeGlobalThis, container) {
53758             if (includeGlobalThis === void 0) { includeGlobalThis = true; }
53759             if (container === void 0) { container = ts.getThisContainer(node, false); }
53760             var isInJS = ts.isInJSFile(node);
53761             if (ts.isFunctionLike(container) &&
53762                 (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) {
53763                 var thisType = getThisTypeOfDeclaration(container) || isInJS && getTypeForThisExpressionFromJSDoc(container);
53764                 if (!thisType) {
53765                     var className = getClassNameFromPrototypeMethod(container);
53766                     if (isInJS && className) {
53767                         var classSymbol = checkExpression(className).symbol;
53768                         if (classSymbol && classSymbol.members && (classSymbol.flags & 16)) {
53769                             thisType = getDeclaredTypeOfSymbol(classSymbol).thisType;
53770                         }
53771                     }
53772                     else if (isJSConstructor(container)) {
53773                         thisType = getDeclaredTypeOfSymbol(getMergedSymbol(container.symbol)).thisType;
53774                     }
53775                     thisType || (thisType = getContextualThisParameterType(container));
53776                 }
53777                 if (thisType) {
53778                     return getFlowTypeOfReference(node, thisType);
53779                 }
53780             }
53781             if (ts.isClassLike(container.parent)) {
53782                 var symbol = getSymbolOfNode(container.parent);
53783                 var type = ts.hasSyntacticModifier(container, 32) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType;
53784                 return getFlowTypeOfReference(node, type);
53785             }
53786             if (ts.isSourceFile(container)) {
53787                 if (container.commonJsModuleIndicator) {
53788                     var fileSymbol = getSymbolOfNode(container);
53789                     return fileSymbol && getTypeOfSymbol(fileSymbol);
53790                 }
53791                 else if (container.externalModuleIndicator) {
53792                     return undefinedType;
53793                 }
53794                 else if (includeGlobalThis) {
53795                     return getTypeOfSymbol(globalThisSymbol);
53796                 }
53797             }
53798         }
53799         function getExplicitThisType(node) {
53800             var container = ts.getThisContainer(node, false);
53801             if (ts.isFunctionLike(container)) {
53802                 var signature = getSignatureFromDeclaration(container);
53803                 if (signature.thisParameter) {
53804                     return getExplicitTypeOfSymbol(signature.thisParameter);
53805                 }
53806             }
53807             if (ts.isClassLike(container.parent)) {
53808                 var symbol = getSymbolOfNode(container.parent);
53809                 return ts.hasSyntacticModifier(container, 32) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType;
53810             }
53811         }
53812         function getClassNameFromPrototypeMethod(container) {
53813             if (container.kind === 208 &&
53814                 ts.isBinaryExpression(container.parent) &&
53815                 ts.getAssignmentDeclarationKind(container.parent) === 3) {
53816                 return container.parent
53817                     .left
53818                     .expression
53819                     .expression;
53820             }
53821             else if (container.kind === 165 &&
53822                 container.parent.kind === 200 &&
53823                 ts.isBinaryExpression(container.parent.parent) &&
53824                 ts.getAssignmentDeclarationKind(container.parent.parent) === 6) {
53825                 return container.parent.parent.left.expression;
53826             }
53827             else if (container.kind === 208 &&
53828                 container.parent.kind === 288 &&
53829                 container.parent.parent.kind === 200 &&
53830                 ts.isBinaryExpression(container.parent.parent.parent) &&
53831                 ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6) {
53832                 return container.parent.parent.parent.left.expression;
53833             }
53834             else if (container.kind === 208 &&
53835                 ts.isPropertyAssignment(container.parent) &&
53836                 ts.isIdentifier(container.parent.name) &&
53837                 (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") &&
53838                 ts.isObjectLiteralExpression(container.parent.parent) &&
53839                 ts.isCallExpression(container.parent.parent.parent) &&
53840                 container.parent.parent.parent.arguments[2] === container.parent.parent &&
53841                 ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9) {
53842                 return container.parent.parent.parent.arguments[0].expression;
53843             }
53844             else if (ts.isMethodDeclaration(container) &&
53845                 ts.isIdentifier(container.name) &&
53846                 (container.name.escapedText === "value" || container.name.escapedText === "get" || container.name.escapedText === "set") &&
53847                 ts.isObjectLiteralExpression(container.parent) &&
53848                 ts.isCallExpression(container.parent.parent) &&
53849                 container.parent.parent.arguments[2] === container.parent &&
53850                 ts.getAssignmentDeclarationKind(container.parent.parent) === 9) {
53851                 return container.parent.parent.arguments[0].expression;
53852             }
53853         }
53854         function getTypeForThisExpressionFromJSDoc(node) {
53855             var jsdocType = ts.getJSDocType(node);
53856             if (jsdocType && jsdocType.kind === 308) {
53857                 var jsDocFunctionType = jsdocType;
53858                 if (jsDocFunctionType.parameters.length > 0 &&
53859                     jsDocFunctionType.parameters[0].name &&
53860                     jsDocFunctionType.parameters[0].name.escapedText === "this") {
53861                     return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type);
53862                 }
53863             }
53864             var thisTag = ts.getJSDocThisTag(node);
53865             if (thisTag && thisTag.typeExpression) {
53866                 return getTypeFromTypeNode(thisTag.typeExpression);
53867             }
53868         }
53869         function isInConstructorArgumentInitializer(node, constructorDecl) {
53870             return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 160 && n.parent === constructorDecl; });
53871         }
53872         function checkSuperExpression(node) {
53873             var isCallExpression = node.parent.kind === 203 && node.parent.expression === node;
53874             var immediateContainer = ts.getSuperContainer(node, true);
53875             var container = immediateContainer;
53876             var needToCaptureLexicalThis = false;
53877             if (!isCallExpression) {
53878                 while (container && container.kind === 209) {
53879                     container = ts.getSuperContainer(container, true);
53880                     needToCaptureLexicalThis = languageVersion < 2;
53881                 }
53882             }
53883             var canUseSuperExpression = isLegalUsageOfSuperExpression(container);
53884             var nodeCheckFlag = 0;
53885             if (!canUseSuperExpression) {
53886                 var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 158; });
53887                 if (current && current.kind === 158) {
53888                     error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name);
53889                 }
53890                 else if (isCallExpression) {
53891                     error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors);
53892                 }
53893                 else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 200)) {
53894                     error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions);
53895                 }
53896                 else {
53897                     error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class);
53898                 }
53899                 return errorType;
53900             }
53901             if (!isCallExpression && immediateContainer.kind === 166) {
53902                 checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class);
53903             }
53904             if (ts.hasSyntacticModifier(container, 32) || isCallExpression) {
53905                 nodeCheckFlag = 512;
53906             }
53907             else {
53908                 nodeCheckFlag = 256;
53909             }
53910             getNodeLinks(node).flags |= nodeCheckFlag;
53911             if (container.kind === 165 && ts.hasSyntacticModifier(container, 256)) {
53912                 if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) {
53913                     getNodeLinks(container).flags |= 4096;
53914                 }
53915                 else {
53916                     getNodeLinks(container).flags |= 2048;
53917                 }
53918             }
53919             if (needToCaptureLexicalThis) {
53920                 captureLexicalThis(node.parent, container);
53921             }
53922             if (container.parent.kind === 200) {
53923                 if (languageVersion < 2) {
53924                     error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher);
53925                     return errorType;
53926                 }
53927                 else {
53928                     return anyType;
53929                 }
53930             }
53931             var classLikeDeclaration = container.parent;
53932             if (!ts.getClassExtendsHeritageElement(classLikeDeclaration)) {
53933                 error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class);
53934                 return errorType;
53935             }
53936             var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(classLikeDeclaration));
53937             var baseClassType = classType && getBaseTypes(classType)[0];
53938             if (!baseClassType) {
53939                 return errorType;
53940             }
53941             if (container.kind === 166 && isInConstructorArgumentInitializer(node, container)) {
53942                 error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments);
53943                 return errorType;
53944             }
53945             return nodeCheckFlag === 512
53946                 ? getBaseConstructorTypeOfClass(classType)
53947                 : getTypeWithThisArgument(baseClassType, classType.thisType);
53948             function isLegalUsageOfSuperExpression(container) {
53949                 if (!container) {
53950                     return false;
53951                 }
53952                 if (isCallExpression) {
53953                     return container.kind === 166;
53954                 }
53955                 else {
53956                     if (ts.isClassLike(container.parent) || container.parent.kind === 200) {
53957                         if (ts.hasSyntacticModifier(container, 32)) {
53958                             return container.kind === 165 ||
53959                                 container.kind === 164 ||
53960                                 container.kind === 167 ||
53961                                 container.kind === 168;
53962                         }
53963                         else {
53964                             return container.kind === 165 ||
53965                                 container.kind === 164 ||
53966                                 container.kind === 167 ||
53967                                 container.kind === 168 ||
53968                                 container.kind === 163 ||
53969                                 container.kind === 162 ||
53970                                 container.kind === 166;
53971                         }
53972                     }
53973                 }
53974                 return false;
53975             }
53976         }
53977         function getContainingObjectLiteral(func) {
53978             return (func.kind === 165 ||
53979                 func.kind === 167 ||
53980                 func.kind === 168) && func.parent.kind === 200 ? func.parent :
53981                 func.kind === 208 && func.parent.kind === 288 ? func.parent.parent :
53982                     undefined;
53983         }
53984         function getThisTypeArgument(type) {
53985             return ts.getObjectFlags(type) & 4 && type.target === globalThisType ? getTypeArguments(type)[0] : undefined;
53986         }
53987         function getThisTypeFromContextualType(type) {
53988             return mapType(type, function (t) {
53989                 return t.flags & 2097152 ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t);
53990             });
53991         }
53992         function getContextualThisParameterType(func) {
53993             if (func.kind === 209) {
53994                 return undefined;
53995             }
53996             if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
53997                 var contextualSignature = getContextualSignature(func);
53998                 if (contextualSignature) {
53999                     var thisParameter = contextualSignature.thisParameter;
54000                     if (thisParameter) {
54001                         return getTypeOfSymbol(thisParameter);
54002                     }
54003                 }
54004             }
54005             var inJs = ts.isInJSFile(func);
54006             if (noImplicitThis || inJs) {
54007                 var containingLiteral = getContainingObjectLiteral(func);
54008                 if (containingLiteral) {
54009                     var contextualType = getApparentTypeOfContextualType(containingLiteral);
54010                     var literal = containingLiteral;
54011                     var type = contextualType;
54012                     while (type) {
54013                         var thisType = getThisTypeFromContextualType(type);
54014                         if (thisType) {
54015                             return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral)));
54016                         }
54017                         if (literal.parent.kind !== 288) {
54018                             break;
54019                         }
54020                         literal = literal.parent.parent;
54021                         type = getApparentTypeOfContextualType(literal);
54022                     }
54023                     return getWidenedType(contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral));
54024                 }
54025                 var parent = ts.walkUpParenthesizedExpressions(func.parent);
54026                 if (parent.kind === 216 && parent.operatorToken.kind === 62) {
54027                     var target = parent.left;
54028                     if (ts.isAccessExpression(target)) {
54029                         var expression = target.expression;
54030                         if (inJs && ts.isIdentifier(expression)) {
54031                             var sourceFile = ts.getSourceFileOfNode(parent);
54032                             if (sourceFile.commonJsModuleIndicator && getResolvedSymbol(expression) === sourceFile.symbol) {
54033                                 return undefined;
54034                             }
54035                         }
54036                         return getWidenedType(checkExpressionCached(expression));
54037                     }
54038                 }
54039             }
54040             return undefined;
54041         }
54042         function getContextuallyTypedParameterType(parameter) {
54043             var func = parameter.parent;
54044             if (!isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
54045                 return undefined;
54046             }
54047             var iife = ts.getImmediatelyInvokedFunctionExpression(func);
54048             if (iife && iife.arguments) {
54049                 var args = getEffectiveCallArguments(iife);
54050                 var indexOfParameter = func.parameters.indexOf(parameter);
54051                 if (parameter.dotDotDotToken) {
54052                     return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, undefined, 0);
54053                 }
54054                 var links = getNodeLinks(iife);
54055                 var cached = links.resolvedSignature;
54056                 links.resolvedSignature = anySignature;
54057                 var type = indexOfParameter < args.length ?
54058                     getWidenedLiteralType(checkExpression(args[indexOfParameter])) :
54059                     parameter.initializer ? undefined : undefinedWideningType;
54060                 links.resolvedSignature = cached;
54061                 return type;
54062             }
54063             var contextualSignature = getContextualSignature(func);
54064             if (contextualSignature) {
54065                 var index = func.parameters.indexOf(parameter) - (ts.getThisParameter(func) ? 1 : 0);
54066                 return parameter.dotDotDotToken && ts.lastOrUndefined(func.parameters) === parameter ?
54067                     getRestTypeAtPosition(contextualSignature, index) :
54068                     tryGetTypeAtPosition(contextualSignature, index);
54069             }
54070         }
54071         function getContextualTypeForVariableLikeDeclaration(declaration) {
54072             var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
54073             if (typeNode) {
54074                 return getTypeFromTypeNode(typeNode);
54075             }
54076             switch (declaration.kind) {
54077                 case 160:
54078                     return getContextuallyTypedParameterType(declaration);
54079                 case 198:
54080                     return getContextualTypeForBindingElement(declaration);
54081                 case 163:
54082                     if (ts.hasSyntacticModifier(declaration, 32)) {
54083                         return getContextualTypeForStaticPropertyDeclaration(declaration);
54084                     }
54085             }
54086         }
54087         function getContextualTypeForBindingElement(declaration) {
54088             var parent = declaration.parent.parent;
54089             var name = declaration.propertyName || declaration.name;
54090             var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
54091                 parent.kind !== 198 && parent.initializer && checkDeclarationInitializer(parent);
54092             if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
54093                 return undefined;
54094             if (parent.name.kind === 197) {
54095                 var index = ts.indexOfNode(declaration.parent.elements, declaration);
54096                 if (index < 0)
54097                     return undefined;
54098                 return getContextualTypeForElementExpression(parentType, index);
54099             }
54100             var nameType = getLiteralTypeFromPropertyName(name);
54101             if (isTypeUsableAsPropertyName(nameType)) {
54102                 var text = getPropertyNameFromType(nameType);
54103                 return getTypeOfPropertyOfType(parentType, text);
54104             }
54105         }
54106         function getContextualTypeForStaticPropertyDeclaration(declaration) {
54107             var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent);
54108             if (!parentType)
54109                 return undefined;
54110             return getTypeOfPropertyOfContextualType(parentType, getSymbolOfNode(declaration).escapedName);
54111         }
54112         function getContextualTypeForInitializerExpression(node, contextFlags) {
54113             var declaration = node.parent;
54114             if (ts.hasInitializer(declaration) && node === declaration.initializer) {
54115                 var result = getContextualTypeForVariableLikeDeclaration(declaration);
54116                 if (result) {
54117                     return result;
54118                 }
54119                 if (!(contextFlags & 8) && ts.isBindingPattern(declaration.name)) {
54120                     return getTypeFromBindingPattern(declaration.name, true, false);
54121                 }
54122             }
54123             return undefined;
54124         }
54125         function getContextualTypeForReturnExpression(node) {
54126             var func = ts.getContainingFunction(node);
54127             if (func) {
54128                 var contextualReturnType = getContextualReturnType(func);
54129                 if (contextualReturnType) {
54130                     var functionFlags = ts.getFunctionFlags(func);
54131                     if (functionFlags & 1) {
54132                         var use = functionFlags & 2 ? 2 : 1;
54133                         var iterationTypes = getIterationTypesOfIterable(contextualReturnType, use, undefined);
54134                         if (!iterationTypes) {
54135                             return undefined;
54136                         }
54137                         contextualReturnType = iterationTypes.returnType;
54138                     }
54139                     if (functionFlags & 2) {
54140                         var contextualAwaitedType = mapType(contextualReturnType, getAwaitedType);
54141                         return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]);
54142                     }
54143                     return contextualReturnType;
54144                 }
54145             }
54146             return undefined;
54147         }
54148         function getContextualTypeForAwaitOperand(node, contextFlags) {
54149             var contextualType = getContextualType(node, contextFlags);
54150             if (contextualType) {
54151                 var contextualAwaitedType = getAwaitedType(contextualType);
54152                 return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]);
54153             }
54154             return undefined;
54155         }
54156         function getContextualTypeForYieldOperand(node) {
54157             var func = ts.getContainingFunction(node);
54158             if (func) {
54159                 var functionFlags = ts.getFunctionFlags(func);
54160                 var contextualReturnType = getContextualReturnType(func);
54161                 if (contextualReturnType) {
54162                     return node.asteriskToken
54163                         ? contextualReturnType
54164                         : getIterationTypeOfGeneratorFunctionReturnType(0, contextualReturnType, (functionFlags & 2) !== 0);
54165                 }
54166             }
54167             return undefined;
54168         }
54169         function isInParameterInitializerBeforeContainingFunction(node) {
54170             var inBindingInitializer = false;
54171             while (node.parent && !ts.isFunctionLike(node.parent)) {
54172                 if (ts.isParameter(node.parent) && (inBindingInitializer || node.parent.initializer === node)) {
54173                     return true;
54174                 }
54175                 if (ts.isBindingElement(node.parent) && node.parent.initializer === node) {
54176                     inBindingInitializer = true;
54177                 }
54178                 node = node.parent;
54179             }
54180             return false;
54181         }
54182         function getContextualIterationType(kind, functionDecl) {
54183             var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2);
54184             var contextualReturnType = getContextualReturnType(functionDecl);
54185             if (contextualReturnType) {
54186                 return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync)
54187                     || undefined;
54188             }
54189             return undefined;
54190         }
54191         function getContextualReturnType(functionDecl) {
54192             var returnType = getReturnTypeFromAnnotation(functionDecl);
54193             if (returnType) {
54194                 return returnType;
54195             }
54196             var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl);
54197             if (signature && !isResolvingReturnTypeOfSignature(signature)) {
54198                 return getReturnTypeOfSignature(signature);
54199             }
54200             return undefined;
54201         }
54202         function getContextualTypeForArgument(callTarget, arg) {
54203             var args = getEffectiveCallArguments(callTarget);
54204             var argIndex = args.indexOf(arg);
54205             return argIndex === -1 ? undefined : getContextualTypeForArgumentAtIndex(callTarget, argIndex);
54206         }
54207         function getContextualTypeForArgumentAtIndex(callTarget, argIndex) {
54208             var signature = getNodeLinks(callTarget).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(callTarget);
54209             if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) {
54210                 return getEffectiveFirstArgumentForJsxSignature(signature, callTarget);
54211             }
54212             return getTypeAtPosition(signature, argIndex);
54213         }
54214         function getContextualTypeForSubstitutionExpression(template, substitutionExpression) {
54215             if (template.parent.kind === 205) {
54216                 return getContextualTypeForArgument(template.parent, substitutionExpression);
54217             }
54218             return undefined;
54219         }
54220         function getContextualTypeForBinaryOperand(node, contextFlags) {
54221             var binaryExpression = node.parent;
54222             var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right;
54223             switch (operatorToken.kind) {
54224                 case 62:
54225                 case 75:
54226                 case 74:
54227                 case 76:
54228                     return node === right ? getContextualTypeForAssignmentDeclaration(binaryExpression) : undefined;
54229                 case 56:
54230                 case 60:
54231                     var type = getContextualType(binaryExpression, contextFlags);
54232                     return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ?
54233                         getTypeOfExpression(left) : type;
54234                 case 55:
54235                 case 27:
54236                     return node === right ? getContextualType(binaryExpression, contextFlags) : undefined;
54237                 default:
54238                     return undefined;
54239             }
54240         }
54241         function getContextualTypeForAssignmentDeclaration(binaryExpression) {
54242             var kind = ts.getAssignmentDeclarationKind(binaryExpression);
54243             switch (kind) {
54244                 case 0:
54245                     return getTypeOfExpression(binaryExpression.left);
54246                 case 5:
54247                 case 1:
54248                 case 6:
54249                 case 3:
54250                     if (isPossiblyAliasedThisProperty(binaryExpression, kind)) {
54251                         return getContextualTypeForThisPropertyAssignment(binaryExpression, kind);
54252                     }
54253                     else if (!binaryExpression.left.symbol) {
54254                         return getTypeOfExpression(binaryExpression.left);
54255                     }
54256                     else {
54257                         var decl = binaryExpression.left.symbol.valueDeclaration;
54258                         if (!decl) {
54259                             return undefined;
54260                         }
54261                         var lhs = ts.cast(binaryExpression.left, ts.isAccessExpression);
54262                         var overallAnnotation = ts.getEffectiveTypeAnnotationNode(decl);
54263                         if (overallAnnotation) {
54264                             return getTypeFromTypeNode(overallAnnotation);
54265                         }
54266                         else if (ts.isIdentifier(lhs.expression)) {
54267                             var id = lhs.expression;
54268                             var parentSymbol = resolveName(id, id.escapedText, 111551, undefined, id.escapedText, true);
54269                             if (parentSymbol) {
54270                                 var annotated = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration);
54271                                 if (annotated) {
54272                                     var nameStr = ts.getElementOrPropertyAccessName(lhs);
54273                                     if (nameStr !== undefined) {
54274                                         return getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr);
54275                                     }
54276                                 }
54277                                 return undefined;
54278                             }
54279                         }
54280                         return ts.isInJSFile(decl) ? undefined : getTypeOfExpression(binaryExpression.left);
54281                     }
54282                 case 2:
54283                 case 4:
54284                     return getContextualTypeForThisPropertyAssignment(binaryExpression, kind);
54285                 case 7:
54286                 case 8:
54287                 case 9:
54288                     return ts.Debug.fail("Does not apply");
54289                 default:
54290                     return ts.Debug.assertNever(kind);
54291             }
54292         }
54293         function isPossiblyAliasedThisProperty(declaration, kind) {
54294             if (kind === void 0) { kind = ts.getAssignmentDeclarationKind(declaration); }
54295             if (kind === 4) {
54296                 return true;
54297             }
54298             if (!ts.isInJSFile(declaration) || kind !== 5 || !ts.isIdentifier(declaration.left.expression)) {
54299                 return false;
54300             }
54301             var name = declaration.left.expression.escapedText;
54302             var symbol = resolveName(declaration.left, name, 111551, undefined, undefined, true, true);
54303             return ts.isThisInitializedDeclaration(symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration);
54304         }
54305         function getContextualTypeForThisPropertyAssignment(binaryExpression, kind) {
54306             if (!binaryExpression.symbol)
54307                 return getTypeOfExpression(binaryExpression.left);
54308             if (binaryExpression.symbol.valueDeclaration) {
54309                 var annotated = ts.getEffectiveTypeAnnotationNode(binaryExpression.symbol.valueDeclaration);
54310                 if (annotated) {
54311                     var type = getTypeFromTypeNode(annotated);
54312                     if (type) {
54313                         return type;
54314                     }
54315                 }
54316             }
54317             if (kind === 2)
54318                 return undefined;
54319             var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression);
54320             if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, false))) {
54321                 return undefined;
54322             }
54323             var thisType = checkThisExpression(thisAccess.expression);
54324             var nameStr = ts.getElementOrPropertyAccessName(thisAccess);
54325             return nameStr !== undefined && getTypeOfPropertyOfContextualType(thisType, nameStr) || undefined;
54326         }
54327         function isCircularMappedProperty(symbol) {
54328             return !!(ts.getCheckFlags(symbol) & 262144 && !symbol.type && findResolutionCycleStartIndex(symbol, 0) >= 0);
54329         }
54330         function getTypeOfPropertyOfContextualType(type, name) {
54331             return mapType(type, function (t) {
54332                 if (isGenericMappedType(t)) {
54333                     var constraint = getConstraintTypeFromMappedType(t);
54334                     var constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
54335                     var propertyNameType = getLiteralType(ts.unescapeLeadingUnderscores(name));
54336                     if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
54337                         return substituteIndexedMappedType(t, propertyNameType);
54338                     }
54339                 }
54340                 else if (t.flags & 3670016) {
54341                     var prop = getPropertyOfType(t, name);
54342                     if (prop) {
54343                         return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop);
54344                     }
54345                     if (isTupleType(t)) {
54346                         var restType = getRestTypeOfTupleType(t);
54347                         if (restType && isNumericLiteralName(name) && +name >= 0) {
54348                             return restType;
54349                         }
54350                     }
54351                     return isNumericLiteralName(name) && getIndexTypeOfContextualType(t, 1) ||
54352                         getIndexTypeOfContextualType(t, 0);
54353                 }
54354                 return undefined;
54355             }, true);
54356         }
54357         function getIndexTypeOfContextualType(type, kind) {
54358             return mapType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }, true);
54359         }
54360         function getContextualTypeForObjectLiteralMethod(node, contextFlags) {
54361             ts.Debug.assert(ts.isObjectLiteralMethod(node));
54362             if (node.flags & 16777216) {
54363                 return undefined;
54364             }
54365             return getContextualTypeForObjectLiteralElement(node, contextFlags);
54366         }
54367         function getContextualTypeForObjectLiteralElement(element, contextFlags) {
54368             var objectLiteral = element.parent;
54369             var type = getApparentTypeOfContextualType(objectLiteral, contextFlags);
54370             if (type) {
54371                 if (!hasNonBindableDynamicName(element)) {
54372                     var symbolName_3 = getSymbolOfNode(element).escapedName;
54373                     var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_3);
54374                     if (propertyType) {
54375                         return propertyType;
54376                     }
54377                 }
54378                 return isNumericName(element.name) && getIndexTypeOfContextualType(type, 1) ||
54379                     getIndexTypeOfContextualType(type, 0);
54380             }
54381             return undefined;
54382         }
54383         function getContextualTypeForElementExpression(arrayContextualType, index) {
54384             return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index)
54385                 || mapType(arrayContextualType, function (t) { return getIteratedTypeOrElementType(1, t, undefinedType, undefined, false); }, true));
54386         }
54387         function getContextualTypeForConditionalOperand(node, contextFlags) {
54388             var conditional = node.parent;
54389             return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional, contextFlags) : undefined;
54390         }
54391         function getContextualTypeForChildJsxExpression(node, child) {
54392             var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName);
54393             var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
54394             if (!(attributesType && !isTypeAny(attributesType) && jsxChildrenPropertyName && jsxChildrenPropertyName !== "")) {
54395                 return undefined;
54396             }
54397             var realChildren = ts.getSemanticJsxChildren(node.children);
54398             var childIndex = realChildren.indexOf(child);
54399             var childFieldType = getTypeOfPropertyOfContextualType(attributesType, jsxChildrenPropertyName);
54400             return childFieldType && (realChildren.length === 1 ? childFieldType : mapType(childFieldType, function (t) {
54401                 if (isArrayLikeType(t)) {
54402                     return getIndexedAccessType(t, getLiteralType(childIndex));
54403                 }
54404                 else {
54405                     return t;
54406                 }
54407             }, true));
54408         }
54409         function getContextualTypeForJsxExpression(node) {
54410             var exprParent = node.parent;
54411             return ts.isJsxAttributeLike(exprParent)
54412                 ? getContextualType(node)
54413                 : ts.isJsxElement(exprParent)
54414                     ? getContextualTypeForChildJsxExpression(exprParent, node)
54415                     : undefined;
54416         }
54417         function getContextualTypeForJsxAttribute(attribute) {
54418             if (ts.isJsxAttribute(attribute)) {
54419                 var attributesType = getApparentTypeOfContextualType(attribute.parent);
54420                 if (!attributesType || isTypeAny(attributesType)) {
54421                     return undefined;
54422                 }
54423                 return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText);
54424             }
54425             else {
54426                 return getContextualType(attribute.parent);
54427             }
54428         }
54429         function isPossiblyDiscriminantValue(node) {
54430             switch (node.kind) {
54431                 case 10:
54432                 case 8:
54433                 case 9:
54434                 case 14:
54435                 case 109:
54436                 case 94:
54437                 case 103:
54438                 case 78:
54439                 case 150:
54440                     return true;
54441                 case 201:
54442                 case 207:
54443                     return isPossiblyDiscriminantValue(node.expression);
54444                 case 283:
54445                     return !node.expression || isPossiblyDiscriminantValue(node.expression);
54446             }
54447             return false;
54448         }
54449         function discriminateContextualTypeByObjectMembers(node, contextualType) {
54450             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);
54451         }
54452         function discriminateContextualTypeByJSXAttributes(node, contextualType) {
54453             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);
54454         }
54455         function getApparentTypeOfContextualType(node, contextFlags) {
54456             var contextualType = ts.isObjectLiteralMethod(node) ?
54457                 getContextualTypeForObjectLiteralMethod(node, contextFlags) :
54458                 getContextualType(node, contextFlags);
54459             var instantiatedType = instantiateContextualType(contextualType, node, contextFlags);
54460             if (instantiatedType && !(contextFlags && contextFlags & 2 && instantiatedType.flags & 8650752)) {
54461                 var apparentType = mapType(instantiatedType, getApparentType, true);
54462                 if (apparentType.flags & 1048576) {
54463                     if (ts.isObjectLiteralExpression(node)) {
54464                         return discriminateContextualTypeByObjectMembers(node, apparentType);
54465                     }
54466                     else if (ts.isJsxAttributes(node)) {
54467                         return discriminateContextualTypeByJSXAttributes(node, apparentType);
54468                     }
54469                 }
54470                 return apparentType;
54471             }
54472         }
54473         function instantiateContextualType(contextualType, node, contextFlags) {
54474             if (contextualType && maybeTypeOfKind(contextualType, 465829888)) {
54475                 var inferenceContext = getInferenceContext(node);
54476                 if (inferenceContext && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
54477                     if (contextFlags && contextFlags & 1) {
54478                         return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
54479                     }
54480                     if (inferenceContext.returnMapper) {
54481                         return instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
54482                     }
54483                 }
54484             }
54485             return contextualType;
54486         }
54487         function instantiateInstantiableTypes(type, mapper) {
54488             if (type.flags & 465829888) {
54489                 return instantiateType(type, mapper);
54490             }
54491             if (type.flags & 1048576) {
54492                 return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0);
54493             }
54494             if (type.flags & 2097152) {
54495                 return getIntersectionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }));
54496             }
54497             return type;
54498         }
54499         function getContextualType(node, contextFlags) {
54500             if (node.flags & 16777216) {
54501                 return undefined;
54502             }
54503             if (node.contextualType) {
54504                 return node.contextualType;
54505             }
54506             var parent = node.parent;
54507             switch (parent.kind) {
54508                 case 249:
54509                 case 160:
54510                 case 163:
54511                 case 162:
54512                 case 198:
54513                     return getContextualTypeForInitializerExpression(node, contextFlags);
54514                 case 209:
54515                 case 242:
54516                     return getContextualTypeForReturnExpression(node);
54517                 case 219:
54518                     return getContextualTypeForYieldOperand(parent);
54519                 case 213:
54520                     return getContextualTypeForAwaitOperand(parent, contextFlags);
54521                 case 203:
54522                     if (parent.expression.kind === 99) {
54523                         return stringType;
54524                     }
54525                 case 204:
54526                     return getContextualTypeForArgument(parent, node);
54527                 case 206:
54528                 case 224:
54529                     return ts.isConstTypeReference(parent.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(parent.type);
54530                 case 216:
54531                     return getContextualTypeForBinaryOperand(node, contextFlags);
54532                 case 288:
54533                 case 289:
54534                     return getContextualTypeForObjectLiteralElement(parent, contextFlags);
54535                 case 290:
54536                     return getApparentTypeOfContextualType(parent.parent, contextFlags);
54537                 case 199: {
54538                     var arrayLiteral = parent;
54539                     var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags);
54540                     return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node));
54541                 }
54542                 case 217:
54543                     return getContextualTypeForConditionalOperand(node, contextFlags);
54544                 case 228:
54545                     ts.Debug.assert(parent.parent.kind === 218);
54546                     return getContextualTypeForSubstitutionExpression(parent.parent, node);
54547                 case 207: {
54548                     var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined;
54549                     return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, contextFlags);
54550                 }
54551                 case 283:
54552                     return getContextualTypeForJsxExpression(parent);
54553                 case 280:
54554                 case 282:
54555                     return getContextualTypeForJsxAttribute(parent);
54556                 case 275:
54557                 case 274:
54558                     return getContextualJsxElementAttributesType(parent, contextFlags);
54559             }
54560             return undefined;
54561             function tryFindWhenConstTypeReference(node) {
54562                 if (ts.isCallLikeExpression(node.parent)) {
54563                     return getContextualTypeForArgument(node.parent, node);
54564                 }
54565                 return undefined;
54566             }
54567         }
54568         function getInferenceContext(node) {
54569             var ancestor = ts.findAncestor(node, function (n) { return !!n.inferenceContext; });
54570             return ancestor && ancestor.inferenceContext;
54571         }
54572         function getContextualJsxElementAttributesType(node, contextFlags) {
54573             if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4) {
54574                 return node.parent.contextualType;
54575             }
54576             return getContextualTypeForArgumentAtIndex(node, 0);
54577         }
54578         function getEffectiveFirstArgumentForJsxSignature(signature, node) {
54579             return getJsxReferenceKind(node) !== 0
54580                 ? getJsxPropsTypeFromCallSignature(signature, node)
54581                 : getJsxPropsTypeFromClassType(signature, node);
54582         }
54583         function getJsxPropsTypeFromCallSignature(sig, context) {
54584             var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, unknownType);
54585             propsType = getJsxManagedAttributesFromLocatedAttributes(context, getJsxNamespaceAt(context), propsType);
54586             var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
54587             if (intrinsicAttribs !== errorType) {
54588                 propsType = intersectTypes(intrinsicAttribs, propsType);
54589             }
54590             return propsType;
54591         }
54592         function getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation) {
54593             if (sig.unionSignatures) {
54594                 var results = [];
54595                 for (var _i = 0, _a = sig.unionSignatures; _i < _a.length; _i++) {
54596                     var signature = _a[_i];
54597                     var instance = getReturnTypeOfSignature(signature);
54598                     if (isTypeAny(instance)) {
54599                         return instance;
54600                     }
54601                     var propType = getTypeOfPropertyOfType(instance, forcedLookupLocation);
54602                     if (!propType) {
54603                         return;
54604                     }
54605                     results.push(propType);
54606                 }
54607                 return getIntersectionType(results);
54608             }
54609             var instanceType = getReturnTypeOfSignature(sig);
54610             return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation);
54611         }
54612         function getStaticTypeOfReferencedJsxConstructor(context) {
54613             if (isJsxIntrinsicIdentifier(context.tagName)) {
54614                 var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(context);
54615                 var fakeSignature = createSignatureForJSXIntrinsic(context, result);
54616                 return getOrCreateTypeFromSignature(fakeSignature);
54617             }
54618             var tagType = checkExpressionCached(context.tagName);
54619             if (tagType.flags & 128) {
54620                 var result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context);
54621                 if (!result) {
54622                     return errorType;
54623                 }
54624                 var fakeSignature = createSignatureForJSXIntrinsic(context, result);
54625                 return getOrCreateTypeFromSignature(fakeSignature);
54626             }
54627             return tagType;
54628         }
54629         function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) {
54630             var managedSym = getJsxLibraryManagedAttributes(ns);
54631             if (managedSym) {
54632                 var declaredManagedType = getDeclaredTypeOfSymbol(managedSym);
54633                 var ctorType = getStaticTypeOfReferencedJsxConstructor(context);
54634                 if (ts.length(declaredManagedType.typeParameters) >= 2) {
54635                     var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.typeParameters, 2, ts.isInJSFile(context));
54636                     return createTypeReference(declaredManagedType, args);
54637                 }
54638                 else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) {
54639                     var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJSFile(context));
54640                     return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args);
54641                 }
54642             }
54643             return attributesType;
54644         }
54645         function getJsxPropsTypeFromClassType(sig, context) {
54646             var ns = getJsxNamespaceAt(context);
54647             var forcedLookupLocation = getJsxElementPropertiesName(ns);
54648             var attributesType = forcedLookupLocation === undefined
54649                 ? getTypeOfFirstParameterOfSignatureWithFallback(sig, unknownType)
54650                 : forcedLookupLocation === ""
54651                     ? getReturnTypeOfSignature(sig)
54652                     : getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation);
54653             if (!attributesType) {
54654                 if (!!forcedLookupLocation && !!ts.length(context.attributes.properties)) {
54655                     error(context, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, ts.unescapeLeadingUnderscores(forcedLookupLocation));
54656                 }
54657                 return unknownType;
54658             }
54659             attributesType = getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType);
54660             if (isTypeAny(attributesType)) {
54661                 return attributesType;
54662             }
54663             else {
54664                 var apparentAttributesType = attributesType;
54665                 var intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes, context);
54666                 if (intrinsicClassAttribs !== errorType) {
54667                     var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol);
54668                     var hostClassType = getReturnTypeOfSignature(sig);
54669                     apparentAttributesType = intersectTypes(typeParams
54670                         ? createTypeReference(intrinsicClassAttribs, fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), ts.isInJSFile(context)))
54671                         : intrinsicClassAttribs, apparentAttributesType);
54672                 }
54673                 var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
54674                 if (intrinsicAttribs !== errorType) {
54675                     apparentAttributesType = intersectTypes(intrinsicAttribs, apparentAttributesType);
54676                 }
54677                 return apparentAttributesType;
54678             }
54679         }
54680         function getContextualCallSignature(type, node) {
54681             var signatures = getSignaturesOfType(type, 0);
54682             if (signatures.length === 1) {
54683                 var signature = signatures[0];
54684                 if (!isAritySmaller(signature, node)) {
54685                     return signature;
54686                 }
54687             }
54688         }
54689         function isAritySmaller(signature, target) {
54690             var targetParameterCount = 0;
54691             for (; targetParameterCount < target.parameters.length; targetParameterCount++) {
54692                 var param = target.parameters[targetParameterCount];
54693                 if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) {
54694                     break;
54695                 }
54696             }
54697             if (target.parameters.length && ts.parameterIsThisKeyword(target.parameters[0])) {
54698                 targetParameterCount--;
54699             }
54700             return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount;
54701         }
54702         function isFunctionExpressionOrArrowFunction(node) {
54703             return node.kind === 208 || node.kind === 209;
54704         }
54705         function getContextualSignatureForFunctionLikeDeclaration(node) {
54706             return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node)
54707                 ? getContextualSignature(node)
54708                 : undefined;
54709         }
54710         function getContextualSignature(node) {
54711             ts.Debug.assert(node.kind !== 165 || ts.isObjectLiteralMethod(node));
54712             var typeTagSignature = getSignatureOfTypeTag(node);
54713             if (typeTagSignature) {
54714                 return typeTagSignature;
54715             }
54716             var type = getApparentTypeOfContextualType(node, 1);
54717             if (!type) {
54718                 return undefined;
54719             }
54720             if (!(type.flags & 1048576)) {
54721                 return getContextualCallSignature(type, node);
54722             }
54723             var signatureList;
54724             var types = type.types;
54725             for (var _i = 0, types_18 = types; _i < types_18.length; _i++) {
54726                 var current = types_18[_i];
54727                 var signature = getContextualCallSignature(current, node);
54728                 if (signature) {
54729                     if (!signatureList) {
54730                         signatureList = [signature];
54731                     }
54732                     else if (!compareSignaturesIdentical(signatureList[0], signature, false, true, true, compareTypesIdentical)) {
54733                         return undefined;
54734                     }
54735                     else {
54736                         signatureList.push(signature);
54737                     }
54738                 }
54739             }
54740             if (signatureList) {
54741                 return signatureList.length === 1 ? signatureList[0] : createUnionSignature(signatureList[0], signatureList);
54742             }
54743         }
54744         function checkSpreadExpression(node, checkMode) {
54745             if (languageVersion < 2) {
54746                 checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 : 2048);
54747             }
54748             var arrayOrIterableType = checkExpression(node.expression, checkMode);
54749             return checkIteratedTypeOrElementType(33, arrayOrIterableType, undefinedType, node.expression);
54750         }
54751         function checkSyntheticExpression(node) {
54752             return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type;
54753         }
54754         function hasDefaultValue(node) {
54755             return (node.kind === 198 && !!node.initializer) ||
54756                 (node.kind === 216 && node.operatorToken.kind === 62);
54757         }
54758         function checkArrayLiteral(node, checkMode, forceTuple) {
54759             var elements = node.elements;
54760             var elementCount = elements.length;
54761             var elementTypes = [];
54762             var elementFlags = [];
54763             var contextualType = getApparentTypeOfContextualType(node);
54764             var inDestructuringPattern = ts.isAssignmentTarget(node);
54765             var inConstContext = isConstContext(node);
54766             for (var i = 0; i < elementCount; i++) {
54767                 var e = elements[i];
54768                 if (e.kind === 220) {
54769                     if (languageVersion < 2) {
54770                         checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 : 2048);
54771                     }
54772                     var spreadType = checkExpression(e.expression, checkMode, forceTuple);
54773                     if (isArrayLikeType(spreadType)) {
54774                         elementTypes.push(spreadType);
54775                         elementFlags.push(8);
54776                     }
54777                     else if (inDestructuringPattern) {
54778                         var restElementType = getIndexTypeOfType(spreadType, 1) ||
54779                             getIteratedTypeOrElementType(65, spreadType, undefinedType, undefined, false) ||
54780                             unknownType;
54781                         elementTypes.push(restElementType);
54782                         elementFlags.push(4);
54783                     }
54784                     else {
54785                         elementTypes.push(checkIteratedTypeOrElementType(33, spreadType, undefinedType, e.expression));
54786                         elementFlags.push(4);
54787                     }
54788                 }
54789                 else {
54790                     var elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length);
54791                     var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple);
54792                     elementTypes.push(type);
54793                     elementFlags.push(1);
54794                 }
54795             }
54796             if (inDestructuringPattern) {
54797                 return createTupleType(elementTypes, elementFlags);
54798             }
54799             if (forceTuple || inConstContext || contextualType && forEachType(contextualType, isTupleLikeType)) {
54800                 return createArrayLiteralType(createTupleType(elementTypes, elementFlags, inConstContext));
54801             }
54802             return createArrayLiteralType(createArrayType(elementTypes.length ?
54803                 getUnionType(ts.sameMap(elementTypes, function (t, i) { return elementFlags[i] & 8 ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t; }), 2) :
54804                 strictNullChecks ? implicitNeverType : undefinedWideningType, inConstContext));
54805         }
54806         function createArrayLiteralType(type) {
54807             if (!(ts.getObjectFlags(type) & 4)) {
54808                 return type;
54809             }
54810             var literalType = type.literalType;
54811             if (!literalType) {
54812                 literalType = type.literalType = cloneTypeReference(type);
54813                 literalType.objectFlags |= 65536 | 1048576;
54814             }
54815             return literalType;
54816         }
54817         function isNumericName(name) {
54818             switch (name.kind) {
54819                 case 158:
54820                     return isNumericComputedName(name);
54821                 case 78:
54822                     return isNumericLiteralName(name.escapedText);
54823                 case 8:
54824                 case 10:
54825                     return isNumericLiteralName(name.text);
54826                 default:
54827                     return false;
54828             }
54829         }
54830         function isNumericComputedName(name) {
54831             return isTypeAssignableToKind(checkComputedPropertyName(name), 296);
54832         }
54833         function isInfinityOrNaNString(name) {
54834             return name === "Infinity" || name === "-Infinity" || name === "NaN";
54835         }
54836         function isNumericLiteralName(name) {
54837             return (+name).toString() === name;
54838         }
54839         function checkComputedPropertyName(node) {
54840             var links = getNodeLinks(node.expression);
54841             if (!links.resolvedType) {
54842                 links.resolvedType = checkExpression(node.expression);
54843                 if (links.resolvedType.flags & 98304 ||
54844                     !isTypeAssignableToKind(links.resolvedType, 402653316 | 296 | 12288) &&
54845                         !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) {
54846                     error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any);
54847                 }
54848                 else {
54849                     checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, true);
54850                 }
54851             }
54852             return links.resolvedType;
54853         }
54854         function isSymbolWithNumericName(symbol) {
54855             var _a;
54856             var firstDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0];
54857             return isNumericLiteralName(symbol.escapedName) || (firstDecl && ts.isNamedDeclaration(firstDecl) && isNumericName(firstDecl.name));
54858         }
54859         function getObjectLiteralIndexInfo(node, offset, properties, kind) {
54860             var propTypes = [];
54861             for (var i = offset; i < properties.length; i++) {
54862                 if (kind === 0 || isSymbolWithNumericName(properties[i])) {
54863                     propTypes.push(getTypeOfSymbol(properties[i]));
54864                 }
54865             }
54866             var unionType = propTypes.length ? getUnionType(propTypes, 2) : undefinedType;
54867             return createIndexInfo(unionType, isConstContext(node));
54868         }
54869         function getImmediateAliasedSymbol(symbol) {
54870             ts.Debug.assert((symbol.flags & 2097152) !== 0, "Should only get Alias here.");
54871             var links = getSymbolLinks(symbol);
54872             if (!links.immediateTarget) {
54873                 var node = getDeclarationOfAliasSymbol(symbol);
54874                 if (!node)
54875                     return ts.Debug.fail();
54876                 links.immediateTarget = getTargetOfAliasDeclaration(node, true);
54877             }
54878             return links.immediateTarget;
54879         }
54880         function checkObjectLiteral(node, checkMode) {
54881             var inDestructuringPattern = ts.isAssignmentTarget(node);
54882             checkGrammarObjectLiteralExpression(node, inDestructuringPattern);
54883             var allPropertiesTable = strictNullChecks ? ts.createSymbolTable() : undefined;
54884             var propertiesTable = ts.createSymbolTable();
54885             var propertiesArray = [];
54886             var spread = emptyObjectType;
54887             var contextualType = getApparentTypeOfContextualType(node);
54888             var contextualTypeHasPattern = contextualType && contextualType.pattern &&
54889                 (contextualType.pattern.kind === 196 || contextualType.pattern.kind === 200);
54890             var inConstContext = isConstContext(node);
54891             var checkFlags = inConstContext ? 8 : 0;
54892             var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node);
54893             var enumTag = ts.getJSDocEnumTag(node);
54894             var isJSObjectLiteral = !contextualType && isInJavascript && !enumTag;
54895             var objectFlags = freshObjectLiteralFlag;
54896             var patternWithComputedProperties = false;
54897             var hasComputedStringProperty = false;
54898             var hasComputedNumberProperty = false;
54899             for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
54900                 var elem = _a[_i];
54901                 if (elem.name && ts.isComputedPropertyName(elem.name) && !ts.isWellKnownSymbolSyntactically(elem.name)) {
54902                     checkComputedPropertyName(elem.name);
54903                 }
54904             }
54905             var offset = 0;
54906             for (var _b = 0, _c = node.properties; _b < _c.length; _b++) {
54907                 var memberDecl = _c[_b];
54908                 var member = getSymbolOfNode(memberDecl);
54909                 var computedNameType = memberDecl.name && memberDecl.name.kind === 158 && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ?
54910                     checkComputedPropertyName(memberDecl.name) : undefined;
54911                 if (memberDecl.kind === 288 ||
54912                     memberDecl.kind === 289 ||
54913                     ts.isObjectLiteralMethod(memberDecl)) {
54914                     var type = memberDecl.kind === 288 ? checkPropertyAssignment(memberDecl, checkMode) :
54915                         memberDecl.kind === 289 ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) :
54916                             checkObjectLiteralMethod(memberDecl, checkMode);
54917                     if (isInJavascript) {
54918                         var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
54919                         if (jsDocType) {
54920                             checkTypeAssignableTo(type, jsDocType, memberDecl);
54921                             type = jsDocType;
54922                         }
54923                         else if (enumTag && enumTag.typeExpression) {
54924                             checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl);
54925                         }
54926                     }
54927                     objectFlags |= ts.getObjectFlags(type) & 3670016;
54928                     var nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined;
54929                     var prop = nameType ?
54930                         createSymbol(4 | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096) :
54931                         createSymbol(4 | member.flags, member.escapedName, checkFlags);
54932                     if (nameType) {
54933                         prop.nameType = nameType;
54934                     }
54935                     if (inDestructuringPattern) {
54936                         var isOptional = (memberDecl.kind === 288 && hasDefaultValue(memberDecl.initializer)) ||
54937                             (memberDecl.kind === 289 && memberDecl.objectAssignmentInitializer);
54938                         if (isOptional) {
54939                             prop.flags |= 16777216;
54940                         }
54941                     }
54942                     else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512)) {
54943                         var impliedProp = getPropertyOfType(contextualType, member.escapedName);
54944                         if (impliedProp) {
54945                             prop.flags |= impliedProp.flags & 16777216;
54946                         }
54947                         else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, 0)) {
54948                             error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType));
54949                         }
54950                     }
54951                     prop.declarations = member.declarations;
54952                     prop.parent = member.parent;
54953                     if (member.valueDeclaration) {
54954                         prop.valueDeclaration = member.valueDeclaration;
54955                     }
54956                     prop.type = type;
54957                     prop.target = member;
54958                     member = prop;
54959                     allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
54960                 }
54961                 else if (memberDecl.kind === 290) {
54962                     if (languageVersion < 2) {
54963                         checkExternalEmitHelpers(memberDecl, 2);
54964                     }
54965                     if (propertiesArray.length > 0) {
54966                         spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext);
54967                         propertiesArray = [];
54968                         propertiesTable = ts.createSymbolTable();
54969                         hasComputedStringProperty = false;
54970                         hasComputedNumberProperty = false;
54971                     }
54972                     var type = getReducedType(checkExpression(memberDecl.expression));
54973                     if (!isValidSpreadType(type)) {
54974                         error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types);
54975                         return errorType;
54976                     }
54977                     if (allPropertiesTable) {
54978                         checkSpreadPropOverrides(type, allPropertiesTable, memberDecl);
54979                     }
54980                     spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext);
54981                     offset = propertiesArray.length;
54982                     continue;
54983                 }
54984                 else {
54985                     ts.Debug.assert(memberDecl.kind === 167 || memberDecl.kind === 168);
54986                     checkNodeDeferred(memberDecl);
54987                 }
54988                 if (computedNameType && !(computedNameType.flags & 8576)) {
54989                     if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) {
54990                         if (isTypeAssignableTo(computedNameType, numberType)) {
54991                             hasComputedNumberProperty = true;
54992                         }
54993                         else {
54994                             hasComputedStringProperty = true;
54995                         }
54996                         if (inDestructuringPattern) {
54997                             patternWithComputedProperties = true;
54998                         }
54999                     }
55000                 }
55001                 else {
55002                     propertiesTable.set(member.escapedName, member);
55003                 }
55004                 propertiesArray.push(member);
55005             }
55006             if (contextualTypeHasPattern && node.parent.kind !== 290) {
55007                 for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) {
55008                     var prop = _e[_d];
55009                     if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) {
55010                         if (!(prop.flags & 16777216)) {
55011                             error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
55012                         }
55013                         propertiesTable.set(prop.escapedName, prop);
55014                         propertiesArray.push(prop);
55015                     }
55016                 }
55017             }
55018             if (spread !== emptyObjectType) {
55019                 if (propertiesArray.length > 0) {
55020                     spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext);
55021                     propertiesArray = [];
55022                     propertiesTable = ts.createSymbolTable();
55023                     hasComputedStringProperty = false;
55024                     hasComputedNumberProperty = false;
55025                 }
55026                 return mapType(spread, function (t) { return t === emptyObjectType ? createObjectLiteralType() : t; });
55027             }
55028             return createObjectLiteralType();
55029             function createObjectLiteralType() {
55030                 var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 0) : undefined;
55031                 var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 1) : undefined;
55032                 var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo);
55033                 result.objectFlags |= objectFlags | 128 | 1048576;
55034                 if (isJSObjectLiteral) {
55035                     result.objectFlags |= 16384;
55036                 }
55037                 if (patternWithComputedProperties) {
55038                     result.objectFlags |= 512;
55039                 }
55040                 if (inDestructuringPattern) {
55041                     result.pattern = node;
55042                 }
55043                 return result;
55044             }
55045         }
55046         function isValidSpreadType(type) {
55047             if (type.flags & 465829888) {
55048                 var constraint = getBaseConstraintOfType(type);
55049                 if (constraint !== undefined) {
55050                     return isValidSpreadType(constraint);
55051                 }
55052             }
55053             return !!(type.flags & (1 | 67108864 | 524288 | 58982400) ||
55054                 getFalsyFlags(type) & 117632 && isValidSpreadType(removeDefinitelyFalsyTypes(type)) ||
55055                 type.flags & 3145728 && ts.every(type.types, isValidSpreadType));
55056         }
55057         function checkJsxSelfClosingElementDeferred(node) {
55058             checkJsxOpeningLikeElementOrOpeningFragment(node);
55059         }
55060         function checkJsxSelfClosingElement(node, _checkMode) {
55061             checkNodeDeferred(node);
55062             return getJsxElementTypeAt(node) || anyType;
55063         }
55064         function checkJsxElementDeferred(node) {
55065             checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement);
55066             if (isJsxIntrinsicIdentifier(node.closingElement.tagName)) {
55067                 getIntrinsicTagSymbol(node.closingElement);
55068             }
55069             else {
55070                 checkExpression(node.closingElement.tagName);
55071             }
55072             checkJsxChildren(node);
55073         }
55074         function checkJsxElement(node, _checkMode) {
55075             checkNodeDeferred(node);
55076             return getJsxElementTypeAt(node) || anyType;
55077         }
55078         function checkJsxFragment(node) {
55079             checkJsxOpeningLikeElementOrOpeningFragment(node.openingFragment);
55080             var nodeSourceFile = ts.getSourceFileOfNode(node);
55081             if (ts.getJSXTransformEnabled(compilerOptions) && (compilerOptions.jsxFactory || nodeSourceFile.pragmas.has("jsx"))
55082                 && !compilerOptions.jsxFragmentFactory && !nodeSourceFile.pragmas.has("jsxfrag")) {
55083                 error(node, compilerOptions.jsxFactory
55084                     ? ts.Diagnostics.The_jsxFragmentFactory_compiler_option_must_be_provided_to_use_JSX_fragments_with_the_jsxFactory_compiler_option
55085                     : ts.Diagnostics.An_jsxFrag_pragma_is_required_when_using_an_jsx_pragma_with_JSX_fragments);
55086             }
55087             checkJsxChildren(node);
55088             return getJsxElementTypeAt(node) || anyType;
55089         }
55090         function isUnhyphenatedJsxName(name) {
55091             return !ts.stringContains(name, "-");
55092         }
55093         function isJsxIntrinsicIdentifier(tagName) {
55094             return tagName.kind === 78 && ts.isIntrinsicJsxName(tagName.escapedText);
55095         }
55096         function checkJsxAttribute(node, checkMode) {
55097             return node.initializer
55098                 ? checkExpressionForMutableLocation(node.initializer, checkMode)
55099                 : trueType;
55100         }
55101         function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, checkMode) {
55102             var attributes = openingLikeElement.attributes;
55103             var allAttributesTable = strictNullChecks ? ts.createSymbolTable() : undefined;
55104             var attributesTable = ts.createSymbolTable();
55105             var spread = emptyJsxObjectType;
55106             var hasSpreadAnyType = false;
55107             var typeToIntersect;
55108             var explicitlySpecifyChildrenAttribute = false;
55109             var objectFlags = 4096;
55110             var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(openingLikeElement));
55111             for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) {
55112                 var attributeDecl = _a[_i];
55113                 var member = attributeDecl.symbol;
55114                 if (ts.isJsxAttribute(attributeDecl)) {
55115                     var exprType = checkJsxAttribute(attributeDecl, checkMode);
55116                     objectFlags |= ts.getObjectFlags(exprType) & 3670016;
55117                     var attributeSymbol = createSymbol(4 | member.flags, member.escapedName);
55118                     attributeSymbol.declarations = member.declarations;
55119                     attributeSymbol.parent = member.parent;
55120                     if (member.valueDeclaration) {
55121                         attributeSymbol.valueDeclaration = member.valueDeclaration;
55122                     }
55123                     attributeSymbol.type = exprType;
55124                     attributeSymbol.target = member;
55125                     attributesTable.set(attributeSymbol.escapedName, attributeSymbol);
55126                     allAttributesTable === null || allAttributesTable === void 0 ? void 0 : allAttributesTable.set(attributeSymbol.escapedName, attributeSymbol);
55127                     if (attributeDecl.name.escapedText === jsxChildrenPropertyName) {
55128                         explicitlySpecifyChildrenAttribute = true;
55129                     }
55130                 }
55131                 else {
55132                     ts.Debug.assert(attributeDecl.kind === 282);
55133                     if (attributesTable.size > 0) {
55134                         spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, false);
55135                         attributesTable = ts.createSymbolTable();
55136                     }
55137                     var exprType = getReducedType(checkExpressionCached(attributeDecl.expression, checkMode));
55138                     if (isTypeAny(exprType)) {
55139                         hasSpreadAnyType = true;
55140                     }
55141                     if (isValidSpreadType(exprType)) {
55142                         spread = getSpreadType(spread, exprType, attributes.symbol, objectFlags, false);
55143                         if (allAttributesTable) {
55144                             checkSpreadPropOverrides(exprType, allAttributesTable, attributeDecl);
55145                         }
55146                     }
55147                     else {
55148                         typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType;
55149                     }
55150                 }
55151             }
55152             if (!hasSpreadAnyType) {
55153                 if (attributesTable.size > 0) {
55154                     spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, false);
55155                 }
55156             }
55157             var parent = openingLikeElement.parent.kind === 273 ? openingLikeElement.parent : undefined;
55158             if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) {
55159                 var childrenTypes = checkJsxChildren(parent, checkMode);
55160                 if (!hasSpreadAnyType && jsxChildrenPropertyName && jsxChildrenPropertyName !== "") {
55161                     if (explicitlySpecifyChildrenAttribute) {
55162                         error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName));
55163                     }
55164                     var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes);
55165                     var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName);
55166                     var childrenPropSymbol = createSymbol(4, jsxChildrenPropertyName);
55167                     childrenPropSymbol.type = childrenTypes.length === 1 ? childrenTypes[0] :
55168                         childrenContextualType && forEachType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) :
55169                             createArrayType(getUnionType(childrenTypes));
55170                     childrenPropSymbol.valueDeclaration = ts.factory.createPropertySignature(undefined, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName), undefined, undefined);
55171                     ts.setParent(childrenPropSymbol.valueDeclaration, attributes);
55172                     childrenPropSymbol.valueDeclaration.symbol = childrenPropSymbol;
55173                     var childPropMap = ts.createSymbolTable();
55174                     childPropMap.set(jsxChildrenPropertyName, childrenPropSymbol);
55175                     spread = getSpreadType(spread, createAnonymousType(attributes.symbol, childPropMap, ts.emptyArray, ts.emptyArray, undefined, undefined), attributes.symbol, objectFlags, false);
55176                 }
55177             }
55178             if (hasSpreadAnyType) {
55179                 return anyType;
55180             }
55181             if (typeToIntersect && spread !== emptyJsxObjectType) {
55182                 return getIntersectionType([typeToIntersect, spread]);
55183             }
55184             return typeToIntersect || (spread === emptyJsxObjectType ? createJsxAttributesType() : spread);
55185             function createJsxAttributesType() {
55186                 objectFlags |= freshObjectLiteralFlag;
55187                 var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, undefined, undefined);
55188                 result.objectFlags |= objectFlags | 128 | 1048576;
55189                 return result;
55190             }
55191         }
55192         function checkJsxChildren(node, checkMode) {
55193             var childrenTypes = [];
55194             for (var _i = 0, _a = node.children; _i < _a.length; _i++) {
55195                 var child = _a[_i];
55196                 if (child.kind === 11) {
55197                     if (!child.containsOnlyTriviaWhiteSpaces) {
55198                         childrenTypes.push(stringType);
55199                     }
55200                 }
55201                 else if (child.kind === 283 && !child.expression) {
55202                     continue;
55203                 }
55204                 else {
55205                     childrenTypes.push(checkExpressionForMutableLocation(child, checkMode));
55206                 }
55207             }
55208             return childrenTypes;
55209         }
55210         function checkSpreadPropOverrides(type, props, spread) {
55211             for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) {
55212                 var right = _a[_i];
55213                 var left = props.get(right.escapedName);
55214                 var rightType = getTypeOfSymbol(right);
55215                 if (left && !maybeTypeOfKind(rightType, 98304) && !(maybeTypeOfKind(rightType, 3) && right.flags & 16777216)) {
55216                     var diagnostic = error(left.valueDeclaration, ts.Diagnostics._0_is_specified_more_than_once_so_this_usage_will_be_overwritten, ts.unescapeLeadingUnderscores(left.escapedName));
55217                     ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(spread, ts.Diagnostics.This_spread_always_overwrites_this_property));
55218                 }
55219             }
55220         }
55221         function checkJsxAttributes(node, checkMode) {
55222             return createJsxAttributesTypeFromAttributesProperty(node.parent, checkMode);
55223         }
55224         function getJsxType(name, location) {
55225             var namespace = getJsxNamespaceAt(location);
55226             var exports = namespace && getExportsOfSymbol(namespace);
55227             var typeSymbol = exports && getSymbol(exports, name, 788968);
55228             return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType;
55229         }
55230         function getIntrinsicTagSymbol(node) {
55231             var links = getNodeLinks(node);
55232             if (!links.resolvedSymbol) {
55233                 var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, node);
55234                 if (intrinsicElementsType !== errorType) {
55235                     if (!ts.isIdentifier(node.tagName))
55236                         return ts.Debug.fail();
55237                     var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.escapedText);
55238                     if (intrinsicProp) {
55239                         links.jsxFlags |= 1;
55240                         return links.resolvedSymbol = intrinsicProp;
55241                     }
55242                     var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0);
55243                     if (indexSignatureType) {
55244                         links.jsxFlags |= 2;
55245                         return links.resolvedSymbol = intrinsicElementsType.symbol;
55246                     }
55247                     error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.idText(node.tagName), "JSX." + JsxNames.IntrinsicElements);
55248                     return links.resolvedSymbol = unknownSymbol;
55249                 }
55250                 else {
55251                     if (noImplicitAny) {
55252                         error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, ts.unescapeLeadingUnderscores(JsxNames.IntrinsicElements));
55253                     }
55254                     return links.resolvedSymbol = unknownSymbol;
55255                 }
55256             }
55257             return links.resolvedSymbol;
55258         }
55259         function getJsxNamespaceContainerForImplicitImport(location) {
55260             var file = location && ts.getSourceFileOfNode(location);
55261             var links = file && getNodeLinks(file);
55262             if (links && links.jsxImplicitImportContainer === false) {
55263                 return undefined;
55264             }
55265             if (links && links.jsxImplicitImportContainer) {
55266                 return links.jsxImplicitImportContainer;
55267             }
55268             var runtimeImportSpecifier = ts.getJSXRuntimeImport(ts.getJSXImplicitImportBase(compilerOptions, file), compilerOptions);
55269             if (!runtimeImportSpecifier) {
55270                 return undefined;
55271             }
55272             var isClassic = ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Classic;
55273             var errorMessage = isClassic
55274                 ? ts.Diagnostics.Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_node_or_to_add_aliases_to_the_paths_option
55275                 : ts.Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations;
55276             var mod = resolveExternalModule(location, runtimeImportSpecifier, errorMessage, location);
55277             var result = mod && mod !== unknownSymbol ? getMergedSymbol(resolveSymbol(mod)) : undefined;
55278             if (links) {
55279                 links.jsxImplicitImportContainer = result || false;
55280             }
55281             return result;
55282         }
55283         function getJsxNamespaceAt(location) {
55284             var links = location && getNodeLinks(location);
55285             if (links && links.jsxNamespace) {
55286                 return links.jsxNamespace;
55287             }
55288             if (!links || links.jsxNamespace !== false) {
55289                 var resolvedNamespace = getJsxNamespaceContainerForImplicitImport(location);
55290                 if (!resolvedNamespace || resolvedNamespace === unknownSymbol) {
55291                     var namespaceName = getJsxNamespace(location);
55292                     resolvedNamespace = resolveName(location, namespaceName, 1920, undefined, namespaceName, false);
55293                 }
55294                 if (resolvedNamespace) {
55295                     var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920));
55296                     if (candidate && candidate !== unknownSymbol) {
55297                         if (links) {
55298                             links.jsxNamespace = candidate;
55299                         }
55300                         return candidate;
55301                     }
55302                 }
55303                 if (links) {
55304                     links.jsxNamespace = false;
55305                 }
55306             }
55307             var s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, 1920, undefined));
55308             if (s === unknownSymbol) {
55309                 return undefined;
55310             }
55311             return s;
55312         }
55313         function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) {
55314             var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968);
55315             var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym);
55316             var propertiesOfJsxElementAttribPropInterface = jsxElementAttribPropInterfaceType && getPropertiesOfType(jsxElementAttribPropInterfaceType);
55317             if (propertiesOfJsxElementAttribPropInterface) {
55318                 if (propertiesOfJsxElementAttribPropInterface.length === 0) {
55319                     return "";
55320                 }
55321                 else if (propertiesOfJsxElementAttribPropInterface.length === 1) {
55322                     return propertiesOfJsxElementAttribPropInterface[0].escapedName;
55323                 }
55324                 else if (propertiesOfJsxElementAttribPropInterface.length > 1) {
55325                     error(jsxElementAttribPropInterfaceSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, ts.unescapeLeadingUnderscores(nameOfAttribPropContainer));
55326                 }
55327             }
55328             return undefined;
55329         }
55330         function getJsxLibraryManagedAttributes(jsxNamespace) {
55331             return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968);
55332         }
55333         function getJsxElementPropertiesName(jsxNamespace) {
55334             return getNameFromJsxElementAttributesContainer(JsxNames.ElementAttributesPropertyNameContainer, jsxNamespace);
55335         }
55336         function getJsxElementChildrenPropertyName(jsxNamespace) {
55337             return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace);
55338         }
55339         function getUninstantiatedJsxSignaturesOfType(elementType, caller) {
55340             if (elementType.flags & 4) {
55341                 return [anySignature];
55342             }
55343             else if (elementType.flags & 128) {
55344                 var intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(elementType, caller);
55345                 if (!intrinsicType) {
55346                     error(caller, ts.Diagnostics.Property_0_does_not_exist_on_type_1, elementType.value, "JSX." + JsxNames.IntrinsicElements);
55347                     return ts.emptyArray;
55348                 }
55349                 else {
55350                     var fakeSignature = createSignatureForJSXIntrinsic(caller, intrinsicType);
55351                     return [fakeSignature];
55352                 }
55353             }
55354             var apparentElemType = getApparentType(elementType);
55355             var signatures = getSignaturesOfType(apparentElemType, 1);
55356             if (signatures.length === 0) {
55357                 signatures = getSignaturesOfType(apparentElemType, 0);
55358             }
55359             if (signatures.length === 0 && apparentElemType.flags & 1048576) {
55360                 signatures = getUnionSignatures(ts.map(apparentElemType.types, function (t) { return getUninstantiatedJsxSignaturesOfType(t, caller); }));
55361             }
55362             return signatures;
55363         }
55364         function getIntrinsicAttributesTypeFromStringLiteralType(type, location) {
55365             var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, location);
55366             if (intrinsicElementsType !== errorType) {
55367                 var stringLiteralTypeName = type.value;
55368                 var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName));
55369                 if (intrinsicProp) {
55370                     return getTypeOfSymbol(intrinsicProp);
55371                 }
55372                 var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0);
55373                 if (indexSignatureType) {
55374                     return indexSignatureType;
55375                 }
55376                 return undefined;
55377             }
55378             return anyType;
55379         }
55380         function checkJsxReturnAssignableToAppropriateBound(refKind, elemInstanceType, openingLikeElement) {
55381             if (refKind === 1) {
55382                 var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement);
55383                 if (sfcReturnConstraint) {
55384                     checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_return_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain);
55385                 }
55386             }
55387             else if (refKind === 0) {
55388                 var classConstraint = getJsxElementClassTypeAt(openingLikeElement);
55389                 if (classConstraint) {
55390                     checkTypeRelatedTo(elemInstanceType, classConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_instance_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain);
55391                 }
55392             }
55393             else {
55394                 var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement);
55395                 var classConstraint = getJsxElementClassTypeAt(openingLikeElement);
55396                 if (!sfcReturnConstraint || !classConstraint) {
55397                     return;
55398                 }
55399                 var combined = getUnionType([sfcReturnConstraint, classConstraint]);
55400                 checkTypeRelatedTo(elemInstanceType, combined, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_element_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain);
55401             }
55402             function generateInitialErrorChain() {
55403                 var componentName = ts.getTextOfNode(openingLikeElement.tagName);
55404                 return ts.chainDiagnosticMessages(undefined, ts.Diagnostics._0_cannot_be_used_as_a_JSX_component, componentName);
55405             }
55406         }
55407         function getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node) {
55408             ts.Debug.assert(isJsxIntrinsicIdentifier(node.tagName));
55409             var links = getNodeLinks(node);
55410             if (!links.resolvedJsxElementAttributesType) {
55411                 var symbol = getIntrinsicTagSymbol(node);
55412                 if (links.jsxFlags & 1) {
55413                     return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol);
55414                 }
55415                 else if (links.jsxFlags & 2) {
55416                     return links.resolvedJsxElementAttributesType =
55417                         getIndexTypeOfType(getDeclaredTypeOfSymbol(symbol), 0);
55418                 }
55419                 else {
55420                     return links.resolvedJsxElementAttributesType = errorType;
55421                 }
55422             }
55423             return links.resolvedJsxElementAttributesType;
55424         }
55425         function getJsxElementClassTypeAt(location) {
55426             var type = getJsxType(JsxNames.ElementClass, location);
55427             if (type === errorType)
55428                 return undefined;
55429             return type;
55430         }
55431         function getJsxElementTypeAt(location) {
55432             return getJsxType(JsxNames.Element, location);
55433         }
55434         function getJsxStatelessElementTypeAt(location) {
55435             var jsxElementType = getJsxElementTypeAt(location);
55436             if (jsxElementType) {
55437                 return getUnionType([jsxElementType, nullType]);
55438             }
55439         }
55440         function getJsxIntrinsicTagNamesAt(location) {
55441             var intrinsics = getJsxType(JsxNames.IntrinsicElements, location);
55442             return intrinsics ? getPropertiesOfType(intrinsics) : ts.emptyArray;
55443         }
55444         function checkJsxPreconditions(errorNode) {
55445             if ((compilerOptions.jsx || 0) === 0) {
55446                 error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided);
55447             }
55448             if (getJsxElementTypeAt(errorNode) === undefined) {
55449                 if (noImplicitAny) {
55450                     error(errorNode, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist);
55451                 }
55452             }
55453         }
55454         function checkJsxOpeningLikeElementOrOpeningFragment(node) {
55455             var isNodeOpeningLikeElement = ts.isJsxOpeningLikeElement(node);
55456             if (isNodeOpeningLikeElement) {
55457                 checkGrammarJsxElement(node);
55458             }
55459             checkJsxPreconditions(node);
55460             if (!getJsxNamespaceContainerForImplicitImport(node)) {
55461                 var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 ? ts.Diagnostics.Cannot_find_name_0 : undefined;
55462                 var jsxFactoryNamespace = getJsxNamespace(node);
55463                 var jsxFactoryLocation = isNodeOpeningLikeElement ? node.tagName : node;
55464                 var jsxFactorySym = void 0;
55465                 if (!(ts.isJsxOpeningFragment(node) && jsxFactoryNamespace === "null")) {
55466                     jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551, jsxFactoryRefErr, jsxFactoryNamespace, true);
55467                 }
55468                 if (jsxFactorySym) {
55469                     jsxFactorySym.isReferenced = 67108863;
55470                     if (jsxFactorySym.flags & 2097152 && !getTypeOnlyAliasDeclaration(jsxFactorySym)) {
55471                         markAliasSymbolAsReferenced(jsxFactorySym);
55472                     }
55473                 }
55474             }
55475             if (isNodeOpeningLikeElement) {
55476                 var jsxOpeningLikeNode = node;
55477                 var sig = getResolvedSignature(jsxOpeningLikeNode);
55478                 checkDeprecatedSignature(sig, node);
55479                 checkJsxReturnAssignableToAppropriateBound(getJsxReferenceKind(jsxOpeningLikeNode), getReturnTypeOfSignature(sig), jsxOpeningLikeNode);
55480             }
55481         }
55482         function isKnownProperty(targetType, name, isComparingJsxAttributes) {
55483             if (targetType.flags & 524288) {
55484                 var resolved = resolveStructuredTypeMembers(targetType);
55485                 if (resolved.stringIndexInfo ||
55486                     resolved.numberIndexInfo && isNumericLiteralName(name) ||
55487                     getPropertyOfObjectType(targetType, name) ||
55488                     isComparingJsxAttributes && !isUnhyphenatedJsxName(name)) {
55489                     return true;
55490                 }
55491             }
55492             else if (targetType.flags & 3145728 && isExcessPropertyCheckTarget(targetType)) {
55493                 for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) {
55494                     var t = _a[_i];
55495                     if (isKnownProperty(t, name, isComparingJsxAttributes)) {
55496                         return true;
55497                     }
55498                 }
55499             }
55500             return false;
55501         }
55502         function isExcessPropertyCheckTarget(type) {
55503             return !!(type.flags & 524288 && !(ts.getObjectFlags(type) & 512) ||
55504                 type.flags & 67108864 ||
55505                 type.flags & 1048576 && ts.some(type.types, isExcessPropertyCheckTarget) ||
55506                 type.flags & 2097152 && ts.every(type.types, isExcessPropertyCheckTarget));
55507         }
55508         function checkJsxExpression(node, checkMode) {
55509             checkGrammarJsxExpression(node);
55510             if (node.expression) {
55511                 var type = checkExpression(node.expression, checkMode);
55512                 if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) {
55513                     error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type);
55514                 }
55515                 return type;
55516             }
55517             else {
55518                 return errorType;
55519             }
55520         }
55521         function getDeclarationNodeFlagsFromSymbol(s) {
55522             return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0;
55523         }
55524         function isPrototypeProperty(symbol) {
55525             if (symbol.flags & 8192 || ts.getCheckFlags(symbol) & 4) {
55526                 return true;
55527             }
55528             if (ts.isInJSFile(symbol.valueDeclaration)) {
55529                 var parent = symbol.valueDeclaration.parent;
55530                 return parent && ts.isBinaryExpression(parent) &&
55531                     ts.getAssignmentDeclarationKind(parent) === 3;
55532             }
55533         }
55534         function checkPropertyAccessibility(node, isSuper, type, prop) {
55535             var flags = ts.getDeclarationModifierFlagsFromSymbol(prop);
55536             var errorNode = node.kind === 157 ? node.right : node.kind === 195 ? node : node.name;
55537             if (isSuper) {
55538                 if (languageVersion < 2) {
55539                     if (symbolHasNonMethodDeclaration(prop)) {
55540                         error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword);
55541                         return false;
55542                     }
55543                 }
55544                 if (flags & 128) {
55545                     error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop)));
55546                     return false;
55547                 }
55548             }
55549             if ((flags & 128) && ts.isThisProperty(node) && symbolHasNonMethodDeclaration(prop)) {
55550                 var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop));
55551                 if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(node)) {
55552                     error(errorNode, ts.Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor, symbolToString(prop), ts.getTextOfIdentifierOrLiteral(declaringClassDeclaration.name));
55553                     return false;
55554                 }
55555             }
55556             if (ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name)) {
55557                 if (!ts.getContainingClass(node)) {
55558                     error(errorNode, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
55559                     return false;
55560                 }
55561                 return true;
55562             }
55563             if (!(flags & 24)) {
55564                 return true;
55565             }
55566             if (flags & 8) {
55567                 var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop));
55568                 if (!isNodeWithinClass(node, declaringClassDeclaration)) {
55569                     error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop)));
55570                     return false;
55571                 }
55572                 return true;
55573             }
55574             if (isSuper) {
55575                 return true;
55576             }
55577             var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) {
55578                 var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration));
55579                 return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined;
55580             });
55581             if (!enclosingClass) {
55582                 var thisParameter = void 0;
55583                 if (flags & 32 || !(thisParameter = getThisParameterFromNodeContext(node)) || !thisParameter.type) {
55584                     error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type));
55585                     return false;
55586                 }
55587                 var thisType = getTypeFromTypeNode(thisParameter.type);
55588                 enclosingClass = ((thisType.flags & 262144) ? getConstraintOfTypeParameter(thisType) : thisType).target;
55589             }
55590             if (flags & 32) {
55591                 return true;
55592             }
55593             if (type.flags & 262144) {
55594                 type = type.isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type);
55595             }
55596             if (!type || !hasBaseType(type, enclosingClass)) {
55597                 error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass));
55598                 return false;
55599             }
55600             return true;
55601         }
55602         function getThisParameterFromNodeContext(node) {
55603             var thisContainer = ts.getThisContainer(node, false);
55604             return thisContainer && ts.isFunctionLike(thisContainer) ? ts.getThisParameter(thisContainer) : undefined;
55605         }
55606         function symbolHasNonMethodDeclaration(symbol) {
55607             return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192); });
55608         }
55609         function checkNonNullExpression(node) {
55610             return checkNonNullType(checkExpression(node), node);
55611         }
55612         function isNullableType(type) {
55613             return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304);
55614         }
55615         function getNonNullableTypeIfNeeded(type) {
55616             return isNullableType(type) ? getNonNullableType(type) : type;
55617         }
55618         function reportObjectPossiblyNullOrUndefinedError(node, flags) {
55619             error(node, flags & 32768 ? flags & 65536 ?
55620                 ts.Diagnostics.Object_is_possibly_null_or_undefined :
55621                 ts.Diagnostics.Object_is_possibly_undefined :
55622                 ts.Diagnostics.Object_is_possibly_null);
55623         }
55624         function reportCannotInvokePossiblyNullOrUndefinedError(node, flags) {
55625             error(node, flags & 32768 ? flags & 65536 ?
55626                 ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined :
55627                 ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined :
55628                 ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null);
55629         }
55630         function checkNonNullTypeWithReporter(type, node, reportError) {
55631             if (strictNullChecks && type.flags & 2) {
55632                 error(node, ts.Diagnostics.Object_is_of_type_unknown);
55633                 return errorType;
55634             }
55635             var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304;
55636             if (kind) {
55637                 reportError(node, kind);
55638                 var t = getNonNullableType(type);
55639                 return t.flags & (98304 | 131072) ? errorType : t;
55640             }
55641             return type;
55642         }
55643         function checkNonNullType(type, node) {
55644             return checkNonNullTypeWithReporter(type, node, reportObjectPossiblyNullOrUndefinedError);
55645         }
55646         function checkNonNullNonVoidType(type, node) {
55647             var nonNullType = checkNonNullType(type, node);
55648             if (nonNullType !== errorType && nonNullType.flags & 16384) {
55649                 error(node, ts.Diagnostics.Object_is_possibly_undefined);
55650             }
55651             return nonNullType;
55652         }
55653         function checkPropertyAccessExpression(node) {
55654             return node.flags & 32 ? checkPropertyAccessChain(node) :
55655                 checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name);
55656         }
55657         function checkPropertyAccessChain(node) {
55658             var leftType = checkExpression(node.expression);
55659             var nonOptionalType = getOptionalExpressionType(leftType, node.expression);
55660             return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), node, nonOptionalType !== leftType);
55661         }
55662         function checkQualifiedName(node) {
55663             return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right);
55664         }
55665         function isMethodAccessForCall(node) {
55666             while (node.parent.kind === 207) {
55667                 node = node.parent;
55668             }
55669             return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node;
55670         }
55671         function lookupSymbolForPrivateIdentifierDeclaration(propName, location) {
55672             for (var containingClass = ts.getContainingClass(location); !!containingClass; containingClass = ts.getContainingClass(containingClass)) {
55673                 var symbol = containingClass.symbol;
55674                 var name = ts.getSymbolNameForPrivateIdentifier(symbol, propName);
55675                 var prop = (symbol.members && symbol.members.get(name)) || (symbol.exports && symbol.exports.get(name));
55676                 if (prop) {
55677                     return prop;
55678                 }
55679             }
55680         }
55681         function getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) {
55682             return getPropertyOfType(leftType, lexicallyScopedIdentifier.escapedName);
55683         }
55684         function checkPrivateIdentifierPropertyAccess(leftType, right, lexicallyScopedIdentifier) {
55685             var propertyOnType;
55686             var properties = getPropertiesOfType(leftType);
55687             if (properties) {
55688                 ts.forEach(properties, function (symbol) {
55689                     var decl = symbol.valueDeclaration;
55690                     if (decl && ts.isNamedDeclaration(decl) && ts.isPrivateIdentifier(decl.name) && decl.name.escapedText === right.escapedText) {
55691                         propertyOnType = symbol;
55692                         return true;
55693                     }
55694                 });
55695             }
55696             var diagName = diagnosticName(right);
55697             if (propertyOnType) {
55698                 var typeValueDecl = propertyOnType.valueDeclaration;
55699                 var typeClass_1 = ts.getContainingClass(typeValueDecl);
55700                 ts.Debug.assert(!!typeClass_1);
55701                 if (lexicallyScopedIdentifier) {
55702                     var lexicalValueDecl = lexicallyScopedIdentifier.valueDeclaration;
55703                     var lexicalClass = ts.getContainingClass(lexicalValueDecl);
55704                     ts.Debug.assert(!!lexicalClass);
55705                     if (ts.findAncestor(lexicalClass, function (n) { return typeClass_1 === n; })) {
55706                         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));
55707                         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));
55708                         return true;
55709                     }
55710                 }
55711                 error(right, ts.Diagnostics.Property_0_is_not_accessible_outside_class_1_because_it_has_a_private_identifier, diagName, diagnosticName(typeClass_1.name || anon));
55712                 return true;
55713             }
55714             return false;
55715         }
55716         function isThisPropertyAccessInConstructor(node, prop) {
55717             return (isConstructorDeclaredProperty(prop) || ts.isThisProperty(node) && isAutoTypedProperty(prop))
55718                 && ts.getThisContainer(node, true) === getDeclaringConstructor(prop);
55719         }
55720         function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) {
55721             var parentSymbol = getNodeLinks(left).resolvedSymbol;
55722             var assignmentKind = ts.getAssignmentTargetKind(node);
55723             var apparentType = getApparentType(assignmentKind !== 0 || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType);
55724             if (ts.isPrivateIdentifier(right)) {
55725                 checkExternalEmitHelpers(node, 1048576);
55726             }
55727             var isAnyLike = isTypeAny(apparentType) || apparentType === silentNeverType;
55728             var prop;
55729             if (ts.isPrivateIdentifier(right)) {
55730                 var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(right.escapedText, right);
55731                 if (isAnyLike) {
55732                     if (lexicallyScopedSymbol) {
55733                         return apparentType;
55734                     }
55735                     if (!ts.getContainingClass(right)) {
55736                         grammarErrorOnNode(right, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
55737                         return anyType;
55738                     }
55739                 }
55740                 prop = lexicallyScopedSymbol ? getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedSymbol) : undefined;
55741                 if (!prop && checkPrivateIdentifierPropertyAccess(leftType, right, lexicallyScopedSymbol)) {
55742                     return errorType;
55743                 }
55744             }
55745             else {
55746                 if (isAnyLike) {
55747                     if (ts.isIdentifier(left) && parentSymbol) {
55748                         markAliasReferenced(parentSymbol, node);
55749                     }
55750                     return apparentType;
55751                 }
55752                 prop = getPropertyOfType(apparentType, right.escapedText);
55753             }
55754             if (ts.isIdentifier(left) && parentSymbol && !(prop && isConstEnumOrConstEnumOnlyModule(prop))) {
55755                 markAliasReferenced(parentSymbol, node);
55756             }
55757             var propType;
55758             if (!prop) {
55759                 var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 || !isGenericObjectType(leftType) || isThisTypeParameter(leftType)) ? getIndexInfoOfType(apparentType, 0) : undefined;
55760                 if (!(indexInfo && indexInfo.type)) {
55761                     if (isJSLiteralType(leftType)) {
55762                         return anyType;
55763                     }
55764                     if (leftType.symbol === globalThisSymbol) {
55765                         if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418)) {
55766                             error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(right.escapedText), typeToString(leftType));
55767                         }
55768                         else if (noImplicitAny) {
55769                             error(right, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(leftType));
55770                         }
55771                         return anyType;
55772                     }
55773                     if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) {
55774                         reportNonexistentProperty(right, isThisTypeParameter(leftType) ? apparentType : leftType);
55775                     }
55776                     return errorType;
55777                 }
55778                 if (indexInfo.isReadonly && (ts.isAssignmentTarget(node) || ts.isDeleteTarget(node))) {
55779                     error(node, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(apparentType));
55780                 }
55781                 propType = (compilerOptions.noUncheckedIndexedAccess && !ts.isAssignmentTarget(node)) ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
55782             }
55783             else {
55784                 if (getDeclarationNodeFlagsFromSymbol(prop) & 134217728 && isUncalledFunctionReference(node, prop)) {
55785                     errorOrSuggestion(false, right, ts.Diagnostics._0_is_deprecated, right.escapedText);
55786                 }
55787                 checkPropertyNotUsedBeforeDeclaration(prop, node, right);
55788                 markPropertyAsReferenced(prop, node, left.kind === 107);
55789                 getNodeLinks(node).resolvedSymbol = prop;
55790                 checkPropertyAccessibility(node, left.kind === 105, apparentType, prop);
55791                 if (isAssignmentToReadonlyEntity(node, prop, assignmentKind)) {
55792                     error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right));
55793                     return errorType;
55794                 }
55795                 propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : getConstraintForLocation(getTypeOfSymbol(prop), node);
55796             }
55797             return getFlowTypeOfAccessExpression(node, prop, propType, right);
55798         }
55799         function getFlowTypeOfAccessExpression(node, prop, propType, errorNode) {
55800             var assignmentKind = ts.getAssignmentTargetKind(node);
55801             if (!ts.isAccessExpression(node) ||
55802                 assignmentKind === 1 ||
55803                 prop && !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 1048576)) {
55804                 return propType;
55805             }
55806             if (propType === autoType) {
55807                 return getFlowTypeOfProperty(node, prop);
55808             }
55809             var assumeUninitialized = false;
55810             if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 107) {
55811                 var declaration = prop && prop.valueDeclaration;
55812                 if (declaration && isInstancePropertyWithoutInitializer(declaration)) {
55813                     var flowContainer = getControlFlowContainer(node);
55814                     if (flowContainer.kind === 166 && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608)) {
55815                         assumeUninitialized = true;
55816                     }
55817                 }
55818             }
55819             else if (strictNullChecks && prop && prop.valueDeclaration &&
55820                 ts.isPropertyAccessExpression(prop.valueDeclaration) &&
55821                 ts.getAssignmentDeclarationPropertyAccessKind(prop.valueDeclaration) &&
55822                 getControlFlowContainer(node) === getControlFlowContainer(prop.valueDeclaration)) {
55823                 assumeUninitialized = true;
55824             }
55825             var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType);
55826             if (assumeUninitialized && !(getFalsyFlags(propType) & 32768) && getFalsyFlags(flowType) & 32768) {
55827                 error(errorNode, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop));
55828                 return propType;
55829             }
55830             return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
55831         }
55832         function checkPropertyNotUsedBeforeDeclaration(prop, node, right) {
55833             var valueDeclaration = prop.valueDeclaration;
55834             if (!valueDeclaration || ts.getSourceFileOfNode(node).isDeclarationFile) {
55835                 return;
55836             }
55837             var diagnosticMessage;
55838             var declarationName = ts.idText(right);
55839             if (isInPropertyInitializer(node)
55840                 && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression))
55841                 && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)
55842                 && !isPropertyDeclaredInAncestorClass(prop)) {
55843                 diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName);
55844             }
55845             else if (valueDeclaration.kind === 252 &&
55846                 node.parent.kind !== 173 &&
55847                 !(valueDeclaration.flags & 8388608) &&
55848                 !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) {
55849                 diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
55850             }
55851             if (diagnosticMessage) {
55852                 ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(valueDeclaration, ts.Diagnostics._0_is_declared_here, declarationName));
55853             }
55854         }
55855         function isInPropertyInitializer(node) {
55856             return !!ts.findAncestor(node, function (node) {
55857                 switch (node.kind) {
55858                     case 163:
55859                         return true;
55860                     case 288:
55861                     case 165:
55862                     case 167:
55863                     case 168:
55864                     case 290:
55865                     case 158:
55866                     case 228:
55867                     case 283:
55868                     case 280:
55869                     case 281:
55870                     case 282:
55871                     case 275:
55872                     case 223:
55873                     case 286:
55874                         return false;
55875                     default:
55876                         return ts.isExpressionNode(node) ? false : "quit";
55877                 }
55878             });
55879         }
55880         function isPropertyDeclaredInAncestorClass(prop) {
55881             if (!(prop.parent.flags & 32)) {
55882                 return false;
55883             }
55884             var classType = getTypeOfSymbol(prop.parent);
55885             while (true) {
55886                 classType = classType.symbol && getSuperClass(classType);
55887                 if (!classType) {
55888                     return false;
55889                 }
55890                 var superProperty = getPropertyOfType(classType, prop.escapedName);
55891                 if (superProperty && superProperty.valueDeclaration) {
55892                     return true;
55893                 }
55894             }
55895         }
55896         function getSuperClass(classType) {
55897             var x = getBaseTypes(classType);
55898             if (x.length === 0) {
55899                 return undefined;
55900             }
55901             return getIntersectionType(x);
55902         }
55903         function reportNonexistentProperty(propNode, containingType) {
55904             var errorInfo;
55905             var relatedInfo;
55906             if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 && !(containingType.flags & 131068)) {
55907                 for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) {
55908                     var subtype = _a[_i];
55909                     if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, 0)) {
55910                         errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype));
55911                         break;
55912                     }
55913                 }
55914             }
55915             if (typeHasStaticProperty(propNode.escapedText, containingType)) {
55916                 errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_is_a_static_member_of_type_1, ts.declarationNameToString(propNode), typeToString(containingType));
55917             }
55918             else {
55919                 var promisedType = getPromisedTypeOfPromise(containingType);
55920                 if (promisedType && getPropertyOfType(promisedType, propNode.escapedText)) {
55921                     errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType));
55922                     relatedInfo = ts.createDiagnosticForNode(propNode, ts.Diagnostics.Did_you_forget_to_use_await);
55923                 }
55924                 else {
55925                     var missingProperty = ts.declarationNameToString(propNode);
55926                     var container = typeToString(containingType);
55927                     var libSuggestion = getSuggestedLibForNonExistentProperty(missingProperty, containingType);
55928                     if (libSuggestion !== undefined) {
55929                         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);
55930                     }
55931                     else {
55932                         var suggestion = getSuggestedSymbolForNonexistentProperty(propNode, containingType);
55933                         if (suggestion !== undefined) {
55934                             var suggestedName = ts.symbolName(suggestion);
55935                             errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, missingProperty, container, suggestedName);
55936                             relatedInfo = suggestion.valueDeclaration && ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestedName);
55937                         }
55938                         else {
55939                             errorInfo = ts.chainDiagnosticMessages(elaborateNeverIntersection(errorInfo, containingType), ts.Diagnostics.Property_0_does_not_exist_on_type_1, missingProperty, container);
55940                         }
55941                     }
55942                 }
55943             }
55944             var resultDiagnostic = ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo);
55945             if (relatedInfo) {
55946                 ts.addRelatedInfo(resultDiagnostic, relatedInfo);
55947             }
55948             diagnostics.add(resultDiagnostic);
55949         }
55950         function typeHasStaticProperty(propName, containingType) {
55951             var prop = containingType.symbol && getPropertyOfType(getTypeOfSymbol(containingType.symbol), propName);
55952             return prop !== undefined && prop.valueDeclaration && ts.hasSyntacticModifier(prop.valueDeclaration, 32);
55953         }
55954         function getSuggestedLibForNonExistentName(name) {
55955             var missingName = diagnosticName(name);
55956             var allFeatures = ts.getScriptTargetFeatures();
55957             var libTargets = ts.getOwnKeys(allFeatures);
55958             for (var _i = 0, libTargets_1 = libTargets; _i < libTargets_1.length; _i++) {
55959                 var libTarget = libTargets_1[_i];
55960                 var containingTypes = ts.getOwnKeys(allFeatures[libTarget]);
55961                 if (containingTypes !== undefined && ts.contains(containingTypes, missingName)) {
55962                     return libTarget;
55963                 }
55964             }
55965         }
55966         function getSuggestedLibForNonExistentProperty(missingProperty, containingType) {
55967             var container = getApparentType(containingType).symbol;
55968             if (!container) {
55969                 return undefined;
55970             }
55971             var allFeatures = ts.getScriptTargetFeatures();
55972             var libTargets = ts.getOwnKeys(allFeatures);
55973             for (var _i = 0, libTargets_2 = libTargets; _i < libTargets_2.length; _i++) {
55974                 var libTarget = libTargets_2[_i];
55975                 var featuresOfLib = allFeatures[libTarget];
55976                 var featuresOfContainingType = featuresOfLib[ts.symbolName(container)];
55977                 if (featuresOfContainingType !== undefined && ts.contains(featuresOfContainingType, missingProperty)) {
55978                     return libTarget;
55979                 }
55980             }
55981         }
55982         function getSuggestedSymbolForNonexistentProperty(name, containingType) {
55983             return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551);
55984         }
55985         function getSuggestedSymbolForNonexistentJSXAttribute(name, containingType) {
55986             var strName = ts.isString(name) ? name : ts.idText(name);
55987             var properties = getPropertiesOfType(containingType);
55988             var jsxSpecific = strName === "for" ? ts.find(properties, function (x) { return ts.symbolName(x) === "htmlFor"; })
55989                 : strName === "class" ? ts.find(properties, function (x) { return ts.symbolName(x) === "className"; })
55990                     : undefined;
55991             return jsxSpecific !== null && jsxSpecific !== void 0 ? jsxSpecific : getSpellingSuggestionForName(strName, properties, 111551);
55992         }
55993         function getSuggestionForNonexistentProperty(name, containingType) {
55994             var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType);
55995             return suggestion && ts.symbolName(suggestion);
55996         }
55997         function getSuggestedSymbolForNonexistentSymbol(location, outerName, meaning) {
55998             ts.Debug.assert(outerName !== undefined, "outername should always be defined");
55999             var result = resolveNameHelper(location, outerName, meaning, undefined, outerName, false, false, function (symbols, name, meaning) {
56000                 ts.Debug.assertEqual(outerName, name, "name should equal outerName");
56001                 var symbol = getSymbol(symbols, name, meaning);
56002                 return symbol || getSpellingSuggestionForName(ts.unescapeLeadingUnderscores(name), ts.arrayFrom(symbols.values()), meaning);
56003             });
56004             return result;
56005         }
56006         function getSuggestionForNonexistentSymbol(location, outerName, meaning) {
56007             var symbolResult = getSuggestedSymbolForNonexistentSymbol(location, outerName, meaning);
56008             return symbolResult && ts.symbolName(symbolResult);
56009         }
56010         function getSuggestedSymbolForNonexistentModule(name, targetModule) {
56011             return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475);
56012         }
56013         function getSuggestionForNonexistentExport(name, targetModule) {
56014             var suggestion = getSuggestedSymbolForNonexistentModule(name, targetModule);
56015             return suggestion && ts.symbolName(suggestion);
56016         }
56017         function getSuggestionForNonexistentIndexSignature(objectType, expr, keyedType) {
56018             function hasProp(name) {
56019                 var prop = getPropertyOfObjectType(objectType, name);
56020                 if (prop) {
56021                     var s = getSingleCallSignature(getTypeOfSymbol(prop));
56022                     return !!s && getMinArgumentCount(s) >= 1 && isTypeAssignableTo(keyedType, getTypeAtPosition(s, 0));
56023                 }
56024                 return false;
56025             }
56026             ;
56027             var suggestedMethod = ts.isAssignmentTarget(expr) ? "set" : "get";
56028             if (!hasProp(suggestedMethod)) {
56029                 return undefined;
56030             }
56031             var suggestion = ts.tryGetPropertyAccessOrIdentifierToString(expr.expression);
56032             if (suggestion === undefined) {
56033                 suggestion = suggestedMethod;
56034             }
56035             else {
56036                 suggestion += "." + suggestedMethod;
56037             }
56038             return suggestion;
56039         }
56040         function getSpellingSuggestionForName(name, symbols, meaning) {
56041             return ts.getSpellingSuggestion(name, symbols, getCandidateName);
56042             function getCandidateName(candidate) {
56043                 var candidateName = ts.symbolName(candidate);
56044                 if (ts.startsWith(candidateName, "\"")) {
56045                     return undefined;
56046                 }
56047                 if (candidate.flags & meaning) {
56048                     return candidateName;
56049                 }
56050                 if (candidate.flags & 2097152) {
56051                     var alias = tryResolveAlias(candidate);
56052                     if (alias && alias.flags & meaning) {
56053                         return candidateName;
56054                     }
56055                 }
56056                 return undefined;
56057             }
56058         }
56059         function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isThisAccess) {
56060             var valueDeclaration = prop && (prop.flags & 106500) && prop.valueDeclaration;
56061             if (!valueDeclaration) {
56062                 return;
56063             }
56064             var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8);
56065             var hasPrivateIdentifier = ts.isNamedDeclaration(prop.valueDeclaration) && ts.isPrivateIdentifier(prop.valueDeclaration.name);
56066             if (!hasPrivateModifier && !hasPrivateIdentifier) {
56067                 return;
56068             }
56069             if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536)) {
56070                 return;
56071             }
56072             if (isThisAccess) {
56073                 var containingMethod = ts.findAncestor(nodeForCheckWriteOnly, ts.isFunctionLikeDeclaration);
56074                 if (containingMethod && containingMethod.symbol === prop) {
56075                     return;
56076                 }
56077             }
56078             (ts.getCheckFlags(prop) & 1 ? getSymbolLinks(prop).target : prop).isReferenced = 67108863;
56079         }
56080         function isValidPropertyAccess(node, propertyName) {
56081             switch (node.kind) {
56082                 case 201:
56083                     return isValidPropertyAccessWithType(node, node.expression.kind === 105, propertyName, getWidenedType(checkExpression(node.expression)));
56084                 case 157:
56085                     return isValidPropertyAccessWithType(node, false, propertyName, getWidenedType(checkExpression(node.left)));
56086                 case 195:
56087                     return isValidPropertyAccessWithType(node, false, propertyName, getTypeFromTypeNode(node));
56088             }
56089         }
56090         function isValidPropertyAccessForCompletions(node, type, property) {
56091             return isValidPropertyAccessWithType(node, node.kind === 201 && node.expression.kind === 105, property.escapedName, type);
56092         }
56093         function isValidPropertyAccessWithType(node, isSuper, propertyName, type) {
56094             if (type === errorType || isTypeAny(type)) {
56095                 return true;
56096             }
56097             var prop = getPropertyOfType(type, propertyName);
56098             if (prop) {
56099                 if (ts.isPropertyAccessExpression(node) && prop.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(prop.valueDeclaration)) {
56100                     var declClass_1 = ts.getContainingClass(prop.valueDeclaration);
56101                     return !ts.isOptionalChain(node) && !!ts.findAncestor(node, function (parent) { return parent === declClass_1; });
56102                 }
56103                 return checkPropertyAccessibility(node, isSuper, type, prop);
56104             }
56105             return ts.isInJSFile(node) && (type.flags & 1048576) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, isSuper, propertyName, elementType); });
56106         }
56107         function getForInVariableSymbol(node) {
56108             var initializer = node.initializer;
56109             if (initializer.kind === 250) {
56110                 var variable = initializer.declarations[0];
56111                 if (variable && !ts.isBindingPattern(variable.name)) {
56112                     return getSymbolOfNode(variable);
56113                 }
56114             }
56115             else if (initializer.kind === 78) {
56116                 return getResolvedSymbol(initializer);
56117             }
56118             return undefined;
56119         }
56120         function hasNumericPropertyNames(type) {
56121             return getIndexTypeOfType(type, 1) && !getIndexTypeOfType(type, 0);
56122         }
56123         function isForInVariableForNumericPropertyNames(expr) {
56124             var e = ts.skipParentheses(expr);
56125             if (e.kind === 78) {
56126                 var symbol = getResolvedSymbol(e);
56127                 if (symbol.flags & 3) {
56128                     var child = expr;
56129                     var node = expr.parent;
56130                     while (node) {
56131                         if (node.kind === 238 &&
56132                             child === node.statement &&
56133                             getForInVariableSymbol(node) === symbol &&
56134                             hasNumericPropertyNames(getTypeOfExpression(node.expression))) {
56135                             return true;
56136                         }
56137                         child = node;
56138                         node = node.parent;
56139                     }
56140                 }
56141             }
56142             return false;
56143         }
56144         function checkIndexedAccess(node) {
56145             return node.flags & 32 ? checkElementAccessChain(node) :
56146                 checkElementAccessExpression(node, checkNonNullExpression(node.expression));
56147         }
56148         function checkElementAccessChain(node) {
56149             var exprType = checkExpression(node.expression);
56150             var nonOptionalType = getOptionalExpressionType(exprType, node.expression);
56151             return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), node, nonOptionalType !== exprType);
56152         }
56153         function checkElementAccessExpression(node, exprType) {
56154             var objectType = ts.getAssignmentTargetKind(node) !== 0 || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType;
56155             var indexExpression = node.argumentExpression;
56156             var indexType = checkExpression(indexExpression);
56157             if (objectType === errorType || objectType === silentNeverType) {
56158                 return objectType;
56159             }
56160             if (isConstEnumObjectType(objectType) && !ts.isStringLiteralLike(indexExpression)) {
56161                 error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal);
56162                 return errorType;
56163             }
56164             var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType;
56165             var accessFlags = ts.isAssignmentTarget(node) ?
56166                 2 | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 : 0) :
56167                 0;
56168             var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, undefined, node, accessFlags | 16) || errorType;
56169             return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node);
56170         }
56171         function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) {
56172             if (expressionType === errorType) {
56173                 return false;
56174             }
56175             if (!ts.isWellKnownSymbolSyntactically(expression)) {
56176                 return false;
56177             }
56178             if ((expressionType.flags & 12288) === 0) {
56179                 if (reportError) {
56180                     error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression));
56181                 }
56182                 return false;
56183             }
56184             var leftHandSide = expression.expression;
56185             var leftHandSideSymbol = getResolvedSymbol(leftHandSide);
56186             if (!leftHandSideSymbol) {
56187                 return false;
56188             }
56189             var globalESSymbol = getGlobalESSymbolConstructorSymbol(true);
56190             if (!globalESSymbol) {
56191                 return false;
56192             }
56193             if (leftHandSideSymbol !== globalESSymbol) {
56194                 if (reportError) {
56195                     error(leftHandSide, ts.Diagnostics.Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object);
56196                 }
56197                 return false;
56198             }
56199             return true;
56200         }
56201         function callLikeExpressionMayHaveTypeArguments(node) {
56202             return ts.isCallOrNewExpression(node) || ts.isTaggedTemplateExpression(node) || ts.isJsxOpeningLikeElement(node);
56203         }
56204         function resolveUntypedCall(node) {
56205             if (callLikeExpressionMayHaveTypeArguments(node)) {
56206                 ts.forEach(node.typeArguments, checkSourceElement);
56207             }
56208             if (node.kind === 205) {
56209                 checkExpression(node.template);
56210             }
56211             else if (ts.isJsxOpeningLikeElement(node)) {
56212                 checkExpression(node.attributes);
56213             }
56214             else if (node.kind !== 161) {
56215                 ts.forEach(node.arguments, function (argument) {
56216                     checkExpression(argument);
56217                 });
56218             }
56219             return anySignature;
56220         }
56221         function resolveErrorCall(node) {
56222             resolveUntypedCall(node);
56223             return unknownSignature;
56224         }
56225         function reorderCandidates(signatures, result, callChainFlags) {
56226             var lastParent;
56227             var lastSymbol;
56228             var cutoffIndex = 0;
56229             var index;
56230             var specializedIndex = -1;
56231             var spliceIndex;
56232             ts.Debug.assert(!result.length);
56233             for (var _i = 0, signatures_7 = signatures; _i < signatures_7.length; _i++) {
56234                 var signature = signatures_7[_i];
56235                 var symbol = signature.declaration && getSymbolOfNode(signature.declaration);
56236                 var parent = signature.declaration && signature.declaration.parent;
56237                 if (!lastSymbol || symbol === lastSymbol) {
56238                     if (lastParent && parent === lastParent) {
56239                         index = index + 1;
56240                     }
56241                     else {
56242                         lastParent = parent;
56243                         index = cutoffIndex;
56244                     }
56245                 }
56246                 else {
56247                     index = cutoffIndex = result.length;
56248                     lastParent = parent;
56249                 }
56250                 lastSymbol = symbol;
56251                 if (signatureHasLiteralTypes(signature)) {
56252                     specializedIndex++;
56253                     spliceIndex = specializedIndex;
56254                     cutoffIndex++;
56255                 }
56256                 else {
56257                     spliceIndex = index;
56258                 }
56259                 result.splice(spliceIndex, 0, callChainFlags ? getOptionalCallSignature(signature, callChainFlags) : signature);
56260             }
56261         }
56262         function isSpreadArgument(arg) {
56263             return !!arg && (arg.kind === 220 || arg.kind === 227 && arg.isSpread);
56264         }
56265         function getSpreadArgumentIndex(args) {
56266             return ts.findIndex(args, isSpreadArgument);
56267         }
56268         function acceptsVoid(t) {
56269             return !!(t.flags & 16384);
56270         }
56271         function acceptsVoidUndefinedUnknownOrAny(t) {
56272             return !!(t.flags & (16384 | 32768 | 2 | 1));
56273         }
56274         function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) {
56275             if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; }
56276             var argCount;
56277             var callIsIncomplete = false;
56278             var effectiveParameterCount = getParameterCount(signature);
56279             var effectiveMinimumArguments = getMinArgumentCount(signature);
56280             if (node.kind === 205) {
56281                 argCount = args.length;
56282                 if (node.template.kind === 218) {
56283                     var lastSpan = ts.last(node.template.templateSpans);
56284                     callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated;
56285                 }
56286                 else {
56287                     var templateLiteral = node.template;
56288                     ts.Debug.assert(templateLiteral.kind === 14);
56289                     callIsIncomplete = !!templateLiteral.isUnterminated;
56290                 }
56291             }
56292             else if (node.kind === 161) {
56293                 argCount = getDecoratorArgumentCount(node, signature);
56294             }
56295             else if (ts.isJsxOpeningLikeElement(node)) {
56296                 callIsIncomplete = node.attributes.end === node.end;
56297                 if (callIsIncomplete) {
56298                     return true;
56299                 }
56300                 argCount = effectiveMinimumArguments === 0 ? args.length : 1;
56301                 effectiveParameterCount = args.length === 0 ? effectiveParameterCount : 1;
56302                 effectiveMinimumArguments = Math.min(effectiveMinimumArguments, 1);
56303             }
56304             else if (!node.arguments) {
56305                 ts.Debug.assert(node.kind === 204);
56306                 return getMinArgumentCount(signature) === 0;
56307             }
56308             else {
56309                 argCount = signatureHelpTrailingComma ? args.length + 1 : args.length;
56310                 callIsIncomplete = node.arguments.end === node.end;
56311                 var spreadArgIndex = getSpreadArgumentIndex(args);
56312                 if (spreadArgIndex >= 0) {
56313                     return spreadArgIndex >= getMinArgumentCount(signature) && (hasEffectiveRestParameter(signature) || spreadArgIndex < getParameterCount(signature));
56314                 }
56315             }
56316             if (!hasEffectiveRestParameter(signature) && argCount > effectiveParameterCount) {
56317                 return false;
56318             }
56319             if (callIsIncomplete || argCount >= effectiveMinimumArguments) {
56320                 return true;
56321             }
56322             for (var i = argCount; i < effectiveMinimumArguments; i++) {
56323                 var type = getTypeAtPosition(signature, i);
56324                 if (filterType(type, ts.isInJSFile(node) && !strictNullChecks ? acceptsVoidUndefinedUnknownOrAny : acceptsVoid).flags & 131072) {
56325                     return false;
56326                 }
56327             }
56328             return true;
56329         }
56330         function hasCorrectTypeArgumentArity(signature, typeArguments) {
56331             var numTypeParameters = ts.length(signature.typeParameters);
56332             var minTypeArgumentCount = getMinTypeArgumentCount(signature.typeParameters);
56333             return !ts.some(typeArguments) ||
56334                 (typeArguments.length >= minTypeArgumentCount && typeArguments.length <= numTypeParameters);
56335         }
56336         function getSingleCallSignature(type) {
56337             return getSingleSignature(type, 0, false);
56338         }
56339         function getSingleCallOrConstructSignature(type) {
56340             return getSingleSignature(type, 0, false) ||
56341                 getSingleSignature(type, 1, false);
56342         }
56343         function getSingleSignature(type, kind, allowMembers) {
56344             if (type.flags & 524288) {
56345                 var resolved = resolveStructuredTypeMembers(type);
56346                 if (allowMembers || resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) {
56347                     if (kind === 0 && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) {
56348                         return resolved.callSignatures[0];
56349                     }
56350                     if (kind === 1 && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) {
56351                         return resolved.constructSignatures[0];
56352                     }
56353                 }
56354             }
56355             return undefined;
56356         }
56357         function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext, compareTypes) {
56358             var context = createInferenceContext(signature.typeParameters, signature, 0, compareTypes);
56359             var restType = getEffectiveRestType(contextualSignature);
56360             var mapper = inferenceContext && (restType && restType.flags & 262144 ? inferenceContext.nonFixingMapper : inferenceContext.mapper);
56361             var sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature;
56362             applyToParameterTypes(sourceSignature, signature, function (source, target) {
56363                 inferTypes(context.inferences, source, target);
56364             });
56365             if (!inferenceContext) {
56366                 applyToReturnTypes(contextualSignature, signature, function (source, target) {
56367                     inferTypes(context.inferences, source, target, 64);
56368                 });
56369             }
56370             return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration));
56371         }
56372         function inferJsxTypeArguments(node, signature, checkMode, context) {
56373             var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node);
56374             var checkAttrType = checkExpressionWithContextualType(node.attributes, paramType, context, checkMode);
56375             inferTypes(context.inferences, checkAttrType, paramType);
56376             return getInferredTypes(context);
56377         }
56378         function inferTypeArguments(node, signature, args, checkMode, context) {
56379             if (ts.isJsxOpeningLikeElement(node)) {
56380                 return inferJsxTypeArguments(node, signature, checkMode, context);
56381             }
56382             if (node.kind !== 161) {
56383                 var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 : 0);
56384                 if (contextualType) {
56385                     var outerContext = getInferenceContext(node);
56386                     var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1));
56387                     var instantiatedType = instantiateType(contextualType, outerMapper);
56388                     var contextualSignature = getSingleCallSignature(instantiatedType);
56389                     var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
56390                         getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
56391                         instantiatedType;
56392                     var inferenceTargetType = getReturnTypeOfSignature(signature);
56393                     inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 64);
56394                     var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags);
56395                     var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
56396                     inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
56397                     context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined;
56398                 }
56399             }
56400             var restType = getNonArrayRestType(signature);
56401             var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length;
56402             if (restType && restType.flags & 262144) {
56403                 var info = ts.find(context.inferences, function (info) { return info.typeParameter === restType; });
56404                 if (info) {
56405                     info.impliedArity = ts.findIndex(args, isSpreadArgument, argCount) < 0 ? args.length - argCount : undefined;
56406                 }
56407             }
56408             var thisType = getThisTypeOfSignature(signature);
56409             if (thisType) {
56410                 var thisArgumentNode = getThisArgumentOfCall(node);
56411                 var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType;
56412                 inferTypes(context.inferences, thisArgumentType, thisType);
56413             }
56414             for (var i = 0; i < argCount; i++) {
56415                 var arg = args[i];
56416                 if (arg.kind !== 222) {
56417                     var paramType = getTypeAtPosition(signature, i);
56418                     var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
56419                     inferTypes(context.inferences, argType, paramType);
56420                 }
56421             }
56422             if (restType) {
56423                 var spreadType = getSpreadArgumentType(args, argCount, args.length, restType, context, checkMode);
56424                 inferTypes(context.inferences, spreadType, restType);
56425             }
56426             return getInferredTypes(context);
56427         }
56428         function getMutableArrayOrTupleType(type) {
56429             return type.flags & 1048576 ? mapType(type, getMutableArrayOrTupleType) :
56430                 type.flags & 1 || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type :
56431                     isTupleType(type) ? createTupleType(getTypeArguments(type), type.target.elementFlags, false, type.target.labeledElementDeclarations) :
56432                         createTupleType([type], [8]);
56433         }
56434         function getSpreadArgumentType(args, index, argCount, restType, context, checkMode) {
56435             if (index >= argCount - 1) {
56436                 var arg = args[argCount - 1];
56437                 if (isSpreadArgument(arg)) {
56438                     return getMutableArrayOrTupleType(arg.kind === 227 ? arg.type :
56439                         checkExpressionWithContextualType(arg.expression, restType, context, checkMode));
56440                 }
56441             }
56442             var types = [];
56443             var flags = [];
56444             var names = [];
56445             for (var i = index; i < argCount; i++) {
56446                 var arg = args[i];
56447                 if (isSpreadArgument(arg)) {
56448                     var spreadType = arg.kind === 227 ? arg.type : checkExpression(arg.expression);
56449                     if (isArrayLikeType(spreadType)) {
56450                         types.push(spreadType);
56451                         flags.push(8);
56452                     }
56453                     else {
56454                         types.push(checkIteratedTypeOrElementType(33, spreadType, undefinedType, arg.kind === 220 ? arg.expression : arg));
56455                         flags.push(4);
56456                     }
56457                 }
56458                 else {
56459                     var contextualType = getIndexedAccessType(restType, getLiteralType(i - index));
56460                     var argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode);
56461                     var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 | 4194304 | 134217728 | 268435456);
56462                     types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType));
56463                     flags.push(1);
56464                 }
56465                 if (arg.kind === 227 && arg.tupleNameSource) {
56466                     names.push(arg.tupleNameSource);
56467                 }
56468             }
56469             return createTupleType(types, flags, false, ts.length(names) === ts.length(types) ? names : undefined);
56470         }
56471         function checkTypeArguments(signature, typeArgumentNodes, reportErrors, headMessage) {
56472             var isJavascript = ts.isInJSFile(signature.declaration);
56473             var typeParameters = signature.typeParameters;
56474             var typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), isJavascript);
56475             var mapper;
56476             for (var i = 0; i < typeArgumentNodes.length; i++) {
56477                 ts.Debug.assert(typeParameters[i] !== undefined, "Should not call checkTypeArguments with too many type arguments");
56478                 var constraint = getConstraintOfTypeParameter(typeParameters[i]);
56479                 if (constraint) {
56480                     var errorInfo = reportErrors && headMessage ? (function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); }) : undefined;
56481                     var typeArgumentHeadMessage = headMessage || ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1;
56482                     if (!mapper) {
56483                         mapper = createTypeMapper(typeParameters, typeArgumentTypes);
56484                     }
56485                     var typeArgument = typeArgumentTypes[i];
56486                     if (!checkTypeAssignableTo(typeArgument, getTypeWithThisArgument(instantiateType(constraint, mapper), typeArgument), reportErrors ? typeArgumentNodes[i] : undefined, typeArgumentHeadMessage, errorInfo)) {
56487                         return undefined;
56488                     }
56489                 }
56490             }
56491             return typeArgumentTypes;
56492         }
56493         function getJsxReferenceKind(node) {
56494             if (isJsxIntrinsicIdentifier(node.tagName)) {
56495                 return 2;
56496             }
56497             var tagType = getApparentType(checkExpression(node.tagName));
56498             if (ts.length(getSignaturesOfType(tagType, 1))) {
56499                 return 0;
56500             }
56501             if (ts.length(getSignaturesOfType(tagType, 0))) {
56502                 return 1;
56503             }
56504             return 2;
56505         }
56506         function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer) {
56507             var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node);
56508             var attributesType = checkExpressionWithContextualType(node.attributes, paramType, undefined, checkMode);
56509             return checkTagNameDoesNotExpectTooManyArguments() && checkTypeRelatedToAndOptionallyElaborate(attributesType, paramType, relation, reportErrors ? node.tagName : undefined, node.attributes, undefined, containingMessageChain, errorOutputContainer);
56510             function checkTagNameDoesNotExpectTooManyArguments() {
56511                 var _a;
56512                 var tagType = ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node) && !isJsxIntrinsicIdentifier(node.tagName) ? checkExpression(node.tagName) : undefined;
56513                 if (!tagType) {
56514                     return true;
56515                 }
56516                 var tagCallSignatures = getSignaturesOfType(tagType, 0);
56517                 if (!ts.length(tagCallSignatures)) {
56518                     return true;
56519                 }
56520                 var factory = getJsxFactoryEntity(node);
56521                 if (!factory) {
56522                     return true;
56523                 }
56524                 var factorySymbol = resolveEntityName(factory, 111551, true, false, node);
56525                 if (!factorySymbol) {
56526                     return true;
56527                 }
56528                 var factoryType = getTypeOfSymbol(factorySymbol);
56529                 var callSignatures = getSignaturesOfType(factoryType, 0);
56530                 if (!ts.length(callSignatures)) {
56531                     return true;
56532                 }
56533                 var hasFirstParamSignatures = false;
56534                 var maxParamCount = 0;
56535                 for (var _i = 0, callSignatures_1 = callSignatures; _i < callSignatures_1.length; _i++) {
56536                     var sig = callSignatures_1[_i];
56537                     var firstparam = getTypeAtPosition(sig, 0);
56538                     var signaturesOfParam = getSignaturesOfType(firstparam, 0);
56539                     if (!ts.length(signaturesOfParam))
56540                         continue;
56541                     for (var _b = 0, signaturesOfParam_1 = signaturesOfParam; _b < signaturesOfParam_1.length; _b++) {
56542                         var paramSig = signaturesOfParam_1[_b];
56543                         hasFirstParamSignatures = true;
56544                         if (hasEffectiveRestParameter(paramSig)) {
56545                             return true;
56546                         }
56547                         var paramCount = getParameterCount(paramSig);
56548                         if (paramCount > maxParamCount) {
56549                             maxParamCount = paramCount;
56550                         }
56551                     }
56552                 }
56553                 if (!hasFirstParamSignatures) {
56554                     return true;
56555                 }
56556                 var absoluteMinArgCount = Infinity;
56557                 for (var _c = 0, tagCallSignatures_1 = tagCallSignatures; _c < tagCallSignatures_1.length; _c++) {
56558                     var tagSig = tagCallSignatures_1[_c];
56559                     var tagRequiredArgCount = getMinArgumentCount(tagSig);
56560                     if (tagRequiredArgCount < absoluteMinArgCount) {
56561                         absoluteMinArgCount = tagRequiredArgCount;
56562                     }
56563                 }
56564                 if (absoluteMinArgCount <= maxParamCount) {
56565                     return true;
56566                 }
56567                 if (reportErrors) {
56568                     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);
56569                     var tagNameDeclaration = (_a = getSymbolAtLocation(node.tagName)) === null || _a === void 0 ? void 0 : _a.valueDeclaration;
56570                     if (tagNameDeclaration) {
56571                         ts.addRelatedInfo(diag, ts.createDiagnosticForNode(tagNameDeclaration, ts.Diagnostics._0_is_declared_here, ts.entityNameToString(node.tagName)));
56572                     }
56573                     if (errorOutputContainer && errorOutputContainer.skipLogging) {
56574                         (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
56575                     }
56576                     if (!errorOutputContainer.skipLogging) {
56577                         diagnostics.add(diag);
56578                     }
56579                 }
56580                 return false;
56581             }
56582         }
56583         function getSignatureApplicabilityError(node, args, signature, relation, checkMode, reportErrors, containingMessageChain) {
56584             var errorOutputContainer = { errors: undefined, skipLogging: true };
56585             if (ts.isJsxOpeningLikeElement(node)) {
56586                 if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer)) {
56587                     ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "jsx should have errors when reporting errors");
56588                     return errorOutputContainer.errors || ts.emptyArray;
56589                 }
56590                 return undefined;
56591             }
56592             var thisType = getThisTypeOfSignature(signature);
56593             if (thisType && thisType !== voidType && node.kind !== 204) {
56594                 var thisArgumentNode = getThisArgumentOfCall(node);
56595                 var thisArgumentType = void 0;
56596                 if (thisArgumentNode) {
56597                     thisArgumentType = checkExpression(thisArgumentNode);
56598                     if (ts.isOptionalChainRoot(thisArgumentNode.parent)) {
56599                         thisArgumentType = getNonNullableType(thisArgumentType);
56600                     }
56601                     else if (ts.isOptionalChain(thisArgumentNode.parent)) {
56602                         thisArgumentType = removeOptionalTypeMarker(thisArgumentType);
56603                     }
56604                 }
56605                 else {
56606                     thisArgumentType = voidType;
56607                 }
56608                 var errorNode = reportErrors ? (thisArgumentNode || node) : undefined;
56609                 var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1;
56610                 if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) {
56611                     ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "this parameter should have errors when reporting errors");
56612                     return errorOutputContainer.errors || ts.emptyArray;
56613                 }
56614             }
56615             var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1;
56616             var restType = getNonArrayRestType(signature);
56617             var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length;
56618             for (var i = 0; i < argCount; i++) {
56619                 var arg = args[i];
56620                 if (arg.kind !== 222) {
56621                     var paramType = getTypeAtPosition(signature, i);
56622                     var argType = checkExpressionWithContextualType(arg, paramType, undefined, checkMode);
56623                     var checkArgType = checkMode & 4 ? getRegularTypeOfObjectLiteral(argType) : argType;
56624                     if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) {
56625                         ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors");
56626                         maybeAddMissingAwaitInfo(arg, checkArgType, paramType);
56627                         return errorOutputContainer.errors || ts.emptyArray;
56628                     }
56629                 }
56630             }
56631             if (restType) {
56632                 var spreadType = getSpreadArgumentType(args, argCount, args.length, restType, undefined, checkMode);
56633                 var errorNode = reportErrors ? argCount < args.length ? args[argCount] : node : undefined;
56634                 if (!checkTypeRelatedTo(spreadType, restType, relation, errorNode, headMessage, undefined, errorOutputContainer)) {
56635                     ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "rest parameter should have errors when reporting errors");
56636                     maybeAddMissingAwaitInfo(errorNode, spreadType, restType);
56637                     return errorOutputContainer.errors || ts.emptyArray;
56638                 }
56639             }
56640             return undefined;
56641             function maybeAddMissingAwaitInfo(errorNode, source, target) {
56642                 if (errorNode && reportErrors && errorOutputContainer.errors && errorOutputContainer.errors.length) {
56643                     if (getAwaitedTypeOfPromise(target)) {
56644                         return;
56645                     }
56646                     var awaitedTypeOfSource = getAwaitedTypeOfPromise(source);
56647                     if (awaitedTypeOfSource && isTypeRelatedTo(awaitedTypeOfSource, target, relation)) {
56648                         ts.addRelatedInfo(errorOutputContainer.errors[0], ts.createDiagnosticForNode(errorNode, ts.Diagnostics.Did_you_forget_to_use_await));
56649                     }
56650                 }
56651             }
56652         }
56653         function getThisArgumentOfCall(node) {
56654             if (node.kind === 203) {
56655                 var callee = ts.skipOuterExpressions(node.expression);
56656                 if (ts.isAccessExpression(callee)) {
56657                     return callee.expression;
56658                 }
56659             }
56660         }
56661         function createSyntheticExpression(parent, type, isSpread, tupleNameSource) {
56662             var result = ts.parseNodeFactory.createSyntheticExpression(type, isSpread, tupleNameSource);
56663             ts.setTextRange(result, parent);
56664             ts.setParent(result, parent);
56665             return result;
56666         }
56667         function getEffectiveCallArguments(node) {
56668             if (node.kind === 205) {
56669                 var template = node.template;
56670                 var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())];
56671                 if (template.kind === 218) {
56672                     ts.forEach(template.templateSpans, function (span) {
56673                         args_3.push(span.expression);
56674                     });
56675                 }
56676                 return args_3;
56677             }
56678             if (node.kind === 161) {
56679                 return getEffectiveDecoratorArguments(node);
56680             }
56681             if (ts.isJsxOpeningLikeElement(node)) {
56682                 return node.attributes.properties.length > 0 || (ts.isJsxOpeningElement(node) && node.parent.children.length > 0) ? [node.attributes] : ts.emptyArray;
56683             }
56684             var args = node.arguments || ts.emptyArray;
56685             var spreadIndex = getSpreadArgumentIndex(args);
56686             if (spreadIndex >= 0) {
56687                 var effectiveArgs_1 = args.slice(0, spreadIndex);
56688                 var _loop_20 = function (i) {
56689                     var arg = args[i];
56690                     var spreadType = arg.kind === 220 && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
56691                     if (spreadType && isTupleType(spreadType)) {
56692                         ts.forEach(getTypeArguments(spreadType), function (t, i) {
56693                             var _a;
56694                             var flags = spreadType.target.elementFlags[i];
56695                             var syntheticArg = createSyntheticExpression(arg, flags & 4 ? createArrayType(t) : t, !!(flags & 12), (_a = spreadType.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]);
56696                             effectiveArgs_1.push(syntheticArg);
56697                         });
56698                     }
56699                     else {
56700                         effectiveArgs_1.push(arg);
56701                     }
56702                 };
56703                 for (var i = spreadIndex; i < args.length; i++) {
56704                     _loop_20(i);
56705                 }
56706                 return effectiveArgs_1;
56707             }
56708             return args;
56709         }
56710         function getEffectiveDecoratorArguments(node) {
56711             var parent = node.parent;
56712             var expr = node.expression;
56713             switch (parent.kind) {
56714                 case 252:
56715                 case 221:
56716                     return [
56717                         createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent)))
56718                     ];
56719                 case 160:
56720                     var func = parent.parent;
56721                     return [
56722                         createSyntheticExpression(expr, parent.parent.kind === 166 ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType),
56723                         createSyntheticExpression(expr, anyType),
56724                         createSyntheticExpression(expr, numberType)
56725                     ];
56726                 case 163:
56727                 case 165:
56728                 case 167:
56729                 case 168:
56730                     var hasPropDesc = parent.kind !== 163 && languageVersion !== 0;
56731                     return [
56732                         createSyntheticExpression(expr, getParentTypeOfClassElement(parent)),
56733                         createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)),
56734                         createSyntheticExpression(expr, hasPropDesc ? createTypedPropertyDescriptorType(getTypeOfNode(parent)) : anyType)
56735                     ];
56736             }
56737             return ts.Debug.fail();
56738         }
56739         function getDecoratorArgumentCount(node, signature) {
56740             switch (node.parent.kind) {
56741                 case 252:
56742                 case 221:
56743                     return 1;
56744                 case 163:
56745                     return 2;
56746                 case 165:
56747                 case 167:
56748                 case 168:
56749                     return languageVersion === 0 || signature.parameters.length <= 2 ? 2 : 3;
56750                 case 160:
56751                     return 3;
56752                 default:
56753                     return ts.Debug.fail();
56754             }
56755         }
56756         function getDiagnosticSpanForCallNode(node, doNotIncludeArguments) {
56757             var start;
56758             var length;
56759             var sourceFile = ts.getSourceFileOfNode(node);
56760             if (ts.isPropertyAccessExpression(node.expression)) {
56761                 var nameSpan = ts.getErrorSpanForNode(sourceFile, node.expression.name);
56762                 start = nameSpan.start;
56763                 length = doNotIncludeArguments ? nameSpan.length : node.end - start;
56764             }
56765             else {
56766                 var expressionSpan = ts.getErrorSpanForNode(sourceFile, node.expression);
56767                 start = expressionSpan.start;
56768                 length = doNotIncludeArguments ? expressionSpan.length : node.end - start;
56769             }
56770             return { start: start, length: length, sourceFile: sourceFile };
56771         }
56772         function getDiagnosticForCallNode(node, message, arg0, arg1, arg2, arg3) {
56773             if (ts.isCallExpression(node)) {
56774                 var _a = getDiagnosticSpanForCallNode(node), sourceFile = _a.sourceFile, start = _a.start, length_5 = _a.length;
56775                 return ts.createFileDiagnostic(sourceFile, start, length_5, message, arg0, arg1, arg2, arg3);
56776             }
56777             else {
56778                 return ts.createDiagnosticForNode(node, message, arg0, arg1, arg2, arg3);
56779             }
56780         }
56781         function isPromiseResolveArityError(node) {
56782             if (!ts.isCallExpression(node) || !ts.isIdentifier(node.expression))
56783                 return false;
56784             var symbol = resolveName(node.expression, node.expression.escapedText, 111551, undefined, undefined, false);
56785             var decl = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration;
56786             if (!decl || !ts.isParameter(decl) || !isFunctionExpressionOrArrowFunction(decl.parent) || !ts.isNewExpression(decl.parent.parent) || !ts.isIdentifier(decl.parent.parent.expression)) {
56787                 return false;
56788             }
56789             var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(false);
56790             if (!globalPromiseSymbol)
56791                 return false;
56792             var constructorSymbol = getSymbolAtLocation(decl.parent.parent.expression, true);
56793             return constructorSymbol === globalPromiseSymbol;
56794         }
56795         function getArgumentArityError(node, signatures, args) {
56796             var min = Number.POSITIVE_INFINITY;
56797             var max = Number.NEGATIVE_INFINITY;
56798             var belowArgCount = Number.NEGATIVE_INFINITY;
56799             var aboveArgCount = Number.POSITIVE_INFINITY;
56800             var argCount = args.length;
56801             var closestSignature;
56802             for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) {
56803                 var sig = signatures_8[_i];
56804                 var minCount = getMinArgumentCount(sig);
56805                 var maxCount = getParameterCount(sig);
56806                 if (minCount < argCount && minCount > belowArgCount)
56807                     belowArgCount = minCount;
56808                 if (argCount < maxCount && maxCount < aboveArgCount)
56809                     aboveArgCount = maxCount;
56810                 if (minCount < min) {
56811                     min = minCount;
56812                     closestSignature = sig;
56813                 }
56814                 max = Math.max(max, maxCount);
56815             }
56816             var hasRestParameter = ts.some(signatures, hasEffectiveRestParameter);
56817             var paramRange = hasRestParameter ? min :
56818                 min < max ? min + "-" + max :
56819                     min;
56820             var hasSpreadArgument = getSpreadArgumentIndex(args) > -1;
56821             if (argCount <= max && hasSpreadArgument) {
56822                 argCount--;
56823             }
56824             var spanArray;
56825             var related;
56826             var error = hasRestParameter || hasSpreadArgument ?
56827                 hasRestParameter && hasSpreadArgument ?
56828                     ts.Diagnostics.Expected_at_least_0_arguments_but_got_1_or_more :
56829                     hasRestParameter ?
56830                         ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 :
56831                         ts.Diagnostics.Expected_0_arguments_but_got_1_or_more :
56832                 paramRange === 1 && argCount === 0 && isPromiseResolveArityError(node) ?
56833                     ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise :
56834                     ts.Diagnostics.Expected_0_arguments_but_got_1;
56835             if (closestSignature && getMinArgumentCount(closestSignature) > argCount && closestSignature.declaration) {
56836                 var paramDecl = closestSignature.declaration.parameters[closestSignature.thisParameter ? argCount + 1 : argCount];
56837                 if (paramDecl) {
56838                     related = ts.createDiagnosticForNode(paramDecl, ts.isBindingPattern(paramDecl.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided :
56839                         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);
56840                 }
56841             }
56842             if (min < argCount && argCount < max) {
56843                 return getDiagnosticForCallNode(node, ts.Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, argCount, belowArgCount, aboveArgCount);
56844             }
56845             if (!hasSpreadArgument && argCount < min) {
56846                 var diagnostic_1 = getDiagnosticForCallNode(node, error, paramRange, argCount);
56847                 return related ? ts.addRelatedInfo(diagnostic_1, related) : diagnostic_1;
56848             }
56849             if (hasRestParameter || hasSpreadArgument) {
56850                 spanArray = ts.factory.createNodeArray(args);
56851                 if (hasSpreadArgument && argCount) {
56852                     var nextArg = ts.elementAt(args, getSpreadArgumentIndex(args) + 1) || undefined;
56853                     spanArray = ts.factory.createNodeArray(args.slice(max > argCount && nextArg ? args.indexOf(nextArg) : Math.min(max, args.length - 1)));
56854                 }
56855             }
56856             else {
56857                 spanArray = ts.factory.createNodeArray(args.slice(max));
56858             }
56859             var pos = ts.first(spanArray).pos;
56860             var end = ts.last(spanArray).end;
56861             if (end === pos) {
56862                 end++;
56863             }
56864             ts.setTextRangePosEnd(spanArray, pos, end);
56865             var diagnostic = ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), spanArray, error, paramRange, argCount);
56866             return related ? ts.addRelatedInfo(diagnostic, related) : diagnostic;
56867         }
56868         function getTypeArgumentArityError(node, signatures, typeArguments) {
56869             var argCount = typeArguments.length;
56870             if (signatures.length === 1) {
56871                 var sig = signatures[0];
56872                 var min_1 = getMinTypeArgumentCount(sig.typeParameters);
56873                 var max = ts.length(sig.typeParameters);
56874                 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);
56875             }
56876             var belowArgCount = -Infinity;
56877             var aboveArgCount = Infinity;
56878             for (var _i = 0, signatures_9 = signatures; _i < signatures_9.length; _i++) {
56879                 var sig = signatures_9[_i];
56880                 var min_2 = getMinTypeArgumentCount(sig.typeParameters);
56881                 var max = ts.length(sig.typeParameters);
56882                 if (min_2 > argCount) {
56883                     aboveArgCount = Math.min(aboveArgCount, min_2);
56884                 }
56885                 else if (max < argCount) {
56886                     belowArgCount = Math.max(belowArgCount, max);
56887                 }
56888             }
56889             if (belowArgCount !== -Infinity && aboveArgCount !== Infinity) {
56890                 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);
56891             }
56892             return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount);
56893         }
56894         function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) {
56895             var isTaggedTemplate = node.kind === 205;
56896             var isDecorator = node.kind === 161;
56897             var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
56898             var reportErrors = !candidatesOutArray && produceDiagnostics;
56899             var typeArguments;
56900             if (!isDecorator) {
56901                 typeArguments = node.typeArguments;
56902                 if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 105) {
56903                     ts.forEach(typeArguments, checkSourceElement);
56904                 }
56905             }
56906             var candidates = candidatesOutArray || [];
56907             reorderCandidates(signatures, candidates, callChainFlags);
56908             if (!candidates.length) {
56909                 if (reportErrors) {
56910                     diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures));
56911                 }
56912                 return resolveErrorCall(node);
56913             }
56914             var args = getEffectiveCallArguments(node);
56915             var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
56916             var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 : 0;
56917             var candidatesForArgumentError;
56918             var candidateForArgumentArityError;
56919             var candidateForTypeArgumentError;
56920             var result;
56921             var signatureHelpTrailingComma = !!(checkMode & 16) && node.kind === 203 && node.arguments.hasTrailingComma;
56922             if (candidates.length > 1) {
56923                 result = chooseOverload(candidates, subtypeRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma);
56924             }
56925             if (!result) {
56926                 result = chooseOverload(candidates, assignableRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma);
56927             }
56928             if (result) {
56929                 return result;
56930             }
56931             if (reportErrors) {
56932                 if (candidatesForArgumentError) {
56933                     if (candidatesForArgumentError.length === 1 || candidatesForArgumentError.length > 3) {
56934                         var last_2 = candidatesForArgumentError[candidatesForArgumentError.length - 1];
56935                         var chain_1;
56936                         if (candidatesForArgumentError.length > 3) {
56937                             chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.The_last_overload_gave_the_following_error);
56938                             chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.No_overload_matches_this_call);
56939                         }
56940                         var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0, true, function () { return chain_1; });
56941                         if (diags) {
56942                             for (var _i = 0, diags_1 = diags; _i < diags_1.length; _i++) {
56943                                 var d = diags_1[_i];
56944                                 if (last_2.declaration && candidatesForArgumentError.length > 3) {
56945                                     ts.addRelatedInfo(d, ts.createDiagnosticForNode(last_2.declaration, ts.Diagnostics.The_last_overload_is_declared_here));
56946                                 }
56947                                 addImplementationSuccessElaboration(last_2, d);
56948                                 diagnostics.add(d);
56949                             }
56950                         }
56951                         else {
56952                             ts.Debug.fail("No error for last overload signature");
56953                         }
56954                     }
56955                     else {
56956                         var allDiagnostics = [];
56957                         var max = 0;
56958                         var min_3 = Number.MAX_VALUE;
56959                         var minIndex = 0;
56960                         var i_1 = 0;
56961                         var _loop_21 = function (c) {
56962                             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)); };
56963                             var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0, true, chain_2);
56964                             if (diags_2) {
56965                                 if (diags_2.length <= min_3) {
56966                                     min_3 = diags_2.length;
56967                                     minIndex = i_1;
56968                                 }
56969                                 max = Math.max(max, diags_2.length);
56970                                 allDiagnostics.push(diags_2);
56971                             }
56972                             else {
56973                                 ts.Debug.fail("No error for 3 or fewer overload signatures");
56974                             }
56975                             i_1++;
56976                         };
56977                         for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
56978                             var c = candidatesForArgumentError_1[_a];
56979                             _loop_21(c);
56980                         }
56981                         var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
56982                         ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
56983                         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);
56984                         var related = __spreadArrays(ts.flatMap(diags_3, function (d) { return d.relatedInformation; }));
56985                         var diag = void 0;
56986                         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; })) {
56987                             var _b = diags_3[0], file = _b.file, start = _b.start, length_6 = _b.length;
56988                             diag = { file: file, start: start, length: length_6, code: chain.code, category: chain.category, messageText: chain, relatedInformation: related };
56989                         }
56990                         else {
56991                             diag = ts.createDiagnosticForNodeFromMessageChain(node, chain, related);
56992                         }
56993                         addImplementationSuccessElaboration(candidatesForArgumentError[0], diag);
56994                         diagnostics.add(diag);
56995                     }
56996                 }
56997                 else if (candidateForArgumentArityError) {
56998                     diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args));
56999                 }
57000                 else if (candidateForTypeArgumentError) {
57001                     checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, true, fallbackError);
57002                 }
57003                 else {
57004                     var signaturesWithCorrectTypeArgumentArity = ts.filter(signatures, function (s) { return hasCorrectTypeArgumentArity(s, typeArguments); });
57005                     if (signaturesWithCorrectTypeArgumentArity.length === 0) {
57006                         diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments));
57007                     }
57008                     else if (!isDecorator) {
57009                         diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args));
57010                     }
57011                     else if (fallbackError) {
57012                         diagnostics.add(getDiagnosticForCallNode(node, fallbackError));
57013                     }
57014                 }
57015             }
57016             return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray);
57017             function addImplementationSuccessElaboration(failed, diagnostic) {
57018                 var _a, _b;
57019                 var oldCandidatesForArgumentError = candidatesForArgumentError;
57020                 var oldCandidateForArgumentArityError = candidateForArgumentArityError;
57021                 var oldCandidateForTypeArgumentError = candidateForTypeArgumentError;
57022                 var declCount = ts.length((_a = failed.declaration) === null || _a === void 0 ? void 0 : _a.symbol.declarations);
57023                 var isOverload = declCount > 1;
57024                 var implDecl = isOverload ? ts.find(((_b = failed.declaration) === null || _b === void 0 ? void 0 : _b.symbol.declarations) || ts.emptyArray, function (d) { return ts.isFunctionLikeDeclaration(d) && ts.nodeIsPresent(d.body); }) : undefined;
57025                 if (implDecl) {
57026                     var candidate = getSignatureFromDeclaration(implDecl);
57027                     var isSingleNonGenericCandidate_1 = !candidate.typeParameters;
57028                     if (chooseOverload([candidate], assignableRelation, isSingleNonGenericCandidate_1)) {
57029                         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));
57030                     }
57031                 }
57032                 candidatesForArgumentError = oldCandidatesForArgumentError;
57033                 candidateForArgumentArityError = oldCandidateForArgumentArityError;
57034                 candidateForTypeArgumentError = oldCandidateForTypeArgumentError;
57035             }
57036             function chooseOverload(candidates, relation, isSingleNonGenericCandidate, signatureHelpTrailingComma) {
57037                 if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; }
57038                 candidatesForArgumentError = undefined;
57039                 candidateForArgumentArityError = undefined;
57040                 candidateForTypeArgumentError = undefined;
57041                 if (isSingleNonGenericCandidate) {
57042                     var candidate = candidates[0];
57043                     if (ts.some(typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) {
57044                         return undefined;
57045                     }
57046                     if (getSignatureApplicabilityError(node, args, candidate, relation, 0, false, undefined)) {
57047                         candidatesForArgumentError = [candidate];
57048                         return undefined;
57049                     }
57050                     return candidate;
57051                 }
57052                 for (var candidateIndex = 0; candidateIndex < candidates.length; candidateIndex++) {
57053                     var candidate = candidates[candidateIndex];
57054                     if (!hasCorrectTypeArgumentArity(candidate, typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) {
57055                         continue;
57056                     }
57057                     var checkCandidate = void 0;
57058                     var inferenceContext = void 0;
57059                     if (candidate.typeParameters) {
57060                         var typeArgumentTypes = void 0;
57061                         if (ts.some(typeArguments)) {
57062                             typeArgumentTypes = checkTypeArguments(candidate, typeArguments, false);
57063                             if (!typeArgumentTypes) {
57064                                 candidateForTypeArgumentError = candidate;
57065                                 continue;
57066                             }
57067                         }
57068                         else {
57069                             inferenceContext = createInferenceContext(candidate.typeParameters, candidate, ts.isInJSFile(node) ? 2 : 0);
57070                             typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8, inferenceContext);
57071                             argCheckMode |= inferenceContext.flags & 4 ? 8 : 0;
57072                         }
57073                         checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
57074                         if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) {
57075                             candidateForArgumentArityError = checkCandidate;
57076                             continue;
57077                         }
57078                     }
57079                     else {
57080                         checkCandidate = candidate;
57081                     }
57082                     if (getSignatureApplicabilityError(node, args, checkCandidate, relation, argCheckMode, false, undefined)) {
57083                         (candidatesForArgumentError || (candidatesForArgumentError = [])).push(checkCandidate);
57084                         continue;
57085                     }
57086                     if (argCheckMode) {
57087                         argCheckMode = 0;
57088                         if (inferenceContext) {
57089                             var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
57090                             checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
57091                             if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) {
57092                                 candidateForArgumentArityError = checkCandidate;
57093                                 continue;
57094                             }
57095                         }
57096                         if (getSignatureApplicabilityError(node, args, checkCandidate, relation, argCheckMode, false, undefined)) {
57097                             (candidatesForArgumentError || (candidatesForArgumentError = [])).push(checkCandidate);
57098                             continue;
57099                         }
57100                     }
57101                     candidates[candidateIndex] = checkCandidate;
57102                     return checkCandidate;
57103                 }
57104                 return undefined;
57105             }
57106         }
57107         function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray) {
57108             ts.Debug.assert(candidates.length > 0);
57109             checkNodeDeferred(node);
57110             return hasCandidatesOutArray || candidates.length === 1 || candidates.some(function (c) { return !!c.typeParameters; })
57111                 ? pickLongestCandidateSignature(node, candidates, args)
57112                 : createUnionOfSignaturesForOverloadFailure(candidates);
57113         }
57114         function createUnionOfSignaturesForOverloadFailure(candidates) {
57115             var thisParameters = ts.mapDefined(candidates, function (c) { return c.thisParameter; });
57116             var thisParameter;
57117             if (thisParameters.length) {
57118                 thisParameter = createCombinedSymbolFromTypes(thisParameters, thisParameters.map(getTypeOfParameter));
57119             }
57120             var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
57121             var parameters = [];
57122             var _loop_22 = function (i) {
57123                 var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
57124                     i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
57125                     i < s.parameters.length ? s.parameters[i] : undefined; });
57126                 ts.Debug.assert(symbols.length !== 0);
57127                 parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
57128             };
57129             for (var i = 0; i < maxNonRestParam; i++) {
57130                 _loop_22(i);
57131             }
57132             var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
57133             var flags = 0;
57134             if (restParameterSymbols.length !== 0) {
57135                 var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2));
57136                 parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type));
57137                 flags |= 1;
57138             }
57139             if (candidates.some(signatureHasLiteralTypes)) {
57140                 flags |= 2;
57141             }
57142             return createSignature(candidates[0].declaration, undefined, thisParameter, parameters, getIntersectionType(candidates.map(getReturnTypeOfSignature)), undefined, minArgumentCount, flags);
57143         }
57144         function getNumNonRestParameters(signature) {
57145             var numParams = signature.parameters.length;
57146             return signatureHasRestParameter(signature) ? numParams - 1 : numParams;
57147         }
57148         function createCombinedSymbolFromTypes(sources, types) {
57149             return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2));
57150         }
57151         function createCombinedSymbolForOverloadFailure(sources, type) {
57152             return createSymbolWithType(ts.first(sources), type);
57153         }
57154         function pickLongestCandidateSignature(node, candidates, args) {
57155             var bestIndex = getLongestCandidateIndex(candidates, apparentArgumentCount === undefined ? args.length : apparentArgumentCount);
57156             var candidate = candidates[bestIndex];
57157             var typeParameters = candidate.typeParameters;
57158             if (!typeParameters) {
57159                 return candidate;
57160             }
57161             var typeArgumentNodes = callLikeExpressionMayHaveTypeArguments(node) ? node.typeArguments : undefined;
57162             var instantiated = typeArgumentNodes
57163                 ? createSignatureInstantiation(candidate, getTypeArgumentsFromNodes(typeArgumentNodes, typeParameters, ts.isInJSFile(node)))
57164                 : inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args);
57165             candidates[bestIndex] = instantiated;
57166             return instantiated;
57167         }
57168         function getTypeArgumentsFromNodes(typeArgumentNodes, typeParameters, isJs) {
57169             var typeArguments = typeArgumentNodes.map(getTypeOfNode);
57170             while (typeArguments.length > typeParameters.length) {
57171                 typeArguments.pop();
57172             }
57173             while (typeArguments.length < typeParameters.length) {
57174                 typeArguments.push(getConstraintOfTypeParameter(typeParameters[typeArguments.length]) || getDefaultTypeArgumentType(isJs));
57175             }
57176             return typeArguments;
57177         }
57178         function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args) {
57179             var inferenceContext = createInferenceContext(typeParameters, candidate, ts.isInJSFile(node) ? 2 : 0);
57180             var typeArgumentTypes = inferTypeArguments(node, candidate, args, 4 | 8, inferenceContext);
57181             return createSignatureInstantiation(candidate, typeArgumentTypes);
57182         }
57183         function getLongestCandidateIndex(candidates, argsCount) {
57184             var maxParamsIndex = -1;
57185             var maxParams = -1;
57186             for (var i = 0; i < candidates.length; i++) {
57187                 var candidate = candidates[i];
57188                 var paramCount = getParameterCount(candidate);
57189                 if (hasEffectiveRestParameter(candidate) || paramCount >= argsCount) {
57190                     return i;
57191                 }
57192                 if (paramCount > maxParams) {
57193                     maxParams = paramCount;
57194                     maxParamsIndex = i;
57195                 }
57196             }
57197             return maxParamsIndex;
57198         }
57199         function resolveCallExpression(node, candidatesOutArray, checkMode) {
57200             if (node.expression.kind === 105) {
57201                 var superType = checkSuperExpression(node.expression);
57202                 if (isTypeAny(superType)) {
57203                     for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) {
57204                         var arg = _a[_i];
57205                         checkExpression(arg);
57206                     }
57207                     return anySignature;
57208                 }
57209                 if (superType !== errorType) {
57210                     var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node));
57211                     if (baseTypeNode) {
57212                         var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode);
57213                         return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0);
57214                     }
57215                 }
57216                 return resolveUntypedCall(node);
57217             }
57218             var callChainFlags;
57219             var funcType = checkExpression(node.expression);
57220             if (ts.isCallChain(node)) {
57221                 var nonOptionalType = getOptionalExpressionType(funcType, node.expression);
57222                 callChainFlags = nonOptionalType === funcType ? 0 :
57223                     ts.isOutermostOptionalChain(node) ? 8 :
57224                         4;
57225                 funcType = nonOptionalType;
57226             }
57227             else {
57228                 callChainFlags = 0;
57229             }
57230             funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError);
57231             if (funcType === silentNeverType) {
57232                 return silentNeverSignature;
57233             }
57234             var apparentType = getApparentType(funcType);
57235             if (apparentType === errorType) {
57236                 return resolveErrorCall(node);
57237             }
57238             var callSignatures = getSignaturesOfType(apparentType, 0);
57239             var numConstructSignatures = getSignaturesOfType(apparentType, 1).length;
57240             if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) {
57241                 if (funcType !== errorType && node.typeArguments) {
57242                     error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
57243                 }
57244                 return resolveUntypedCall(node);
57245             }
57246             if (!callSignatures.length) {
57247                 if (numConstructSignatures) {
57248                     error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
57249                 }
57250                 else {
57251                     var relatedInformation = void 0;
57252                     if (node.arguments.length === 1) {
57253                         var text = ts.getSourceFileOfNode(node).text;
57254                         if (ts.isLineBreak(text.charCodeAt(ts.skipTrivia(text, node.expression.end, true) - 1))) {
57255                             relatedInformation = ts.createDiagnosticForNode(node.expression, ts.Diagnostics.Are_you_missing_a_semicolon);
57256                         }
57257                     }
57258                     invocationError(node.expression, apparentType, 0, relatedInformation);
57259                 }
57260                 return resolveErrorCall(node);
57261             }
57262             if (checkMode & 8 && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) {
57263                 skippedGenericFunction(node, checkMode);
57264                 return resolvingSignature;
57265             }
57266             if (callSignatures.some(function (sig) { return ts.isInJSFile(sig.declaration) && !!ts.getJSDocClassTag(sig.declaration); })) {
57267                 error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
57268                 return resolveErrorCall(node);
57269             }
57270             return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
57271         }
57272         function isGenericFunctionReturningFunction(signature) {
57273             return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
57274         }
57275         function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) {
57276             return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144) ||
57277                 !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (1048576 | 131072)) && isTypeAssignableTo(funcType, globalFunctionType);
57278         }
57279         function resolveNewExpression(node, candidatesOutArray, checkMode) {
57280             if (node.arguments && languageVersion < 1) {
57281                 var spreadIndex = getSpreadArgumentIndex(node.arguments);
57282                 if (spreadIndex >= 0) {
57283                     error(node.arguments[spreadIndex], ts.Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher);
57284                 }
57285             }
57286             var expressionType = checkNonNullExpression(node.expression);
57287             if (expressionType === silentNeverType) {
57288                 return silentNeverSignature;
57289             }
57290             expressionType = getApparentType(expressionType);
57291             if (expressionType === errorType) {
57292                 return resolveErrorCall(node);
57293             }
57294             if (isTypeAny(expressionType)) {
57295                 if (node.typeArguments) {
57296                     error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
57297                 }
57298                 return resolveUntypedCall(node);
57299             }
57300             var constructSignatures = getSignaturesOfType(expressionType, 1);
57301             if (constructSignatures.length) {
57302                 if (!isConstructorAccessible(node, constructSignatures[0])) {
57303                     return resolveErrorCall(node);
57304                 }
57305                 var valueDecl = expressionType.symbol && ts.getClassLikeDeclarationOfSymbol(expressionType.symbol);
57306                 if (valueDecl && ts.hasSyntacticModifier(valueDecl, 128)) {
57307                     error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class);
57308                     return resolveErrorCall(node);
57309                 }
57310                 return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0);
57311             }
57312             var callSignatures = getSignaturesOfType(expressionType, 0);
57313             if (callSignatures.length) {
57314                 var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0);
57315                 if (!noImplicitAny) {
57316                     if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) {
57317                         error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword);
57318                     }
57319                     if (getThisTypeOfSignature(signature) === voidType) {
57320                         error(node, ts.Diagnostics.A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void);
57321                     }
57322                 }
57323                 return signature;
57324             }
57325             invocationError(node.expression, expressionType, 1);
57326             return resolveErrorCall(node);
57327         }
57328         function typeHasProtectedAccessibleBase(target, type) {
57329             var baseTypes = getBaseTypes(type);
57330             if (!ts.length(baseTypes)) {
57331                 return false;
57332             }
57333             var firstBase = baseTypes[0];
57334             if (firstBase.flags & 2097152) {
57335                 var types = firstBase.types;
57336                 var mixinFlags = findMixins(types);
57337                 var i = 0;
57338                 for (var _i = 0, _a = firstBase.types; _i < _a.length; _i++) {
57339                     var intersectionMember = _a[_i];
57340                     if (!mixinFlags[i]) {
57341                         if (ts.getObjectFlags(intersectionMember) & (1 | 2)) {
57342                             if (intersectionMember.symbol === target) {
57343                                 return true;
57344                             }
57345                             if (typeHasProtectedAccessibleBase(target, intersectionMember)) {
57346                                 return true;
57347                             }
57348                         }
57349                     }
57350                     i++;
57351                 }
57352                 return false;
57353             }
57354             if (firstBase.symbol === target) {
57355                 return true;
57356             }
57357             return typeHasProtectedAccessibleBase(target, firstBase);
57358         }
57359         function isConstructorAccessible(node, signature) {
57360             if (!signature || !signature.declaration) {
57361                 return true;
57362             }
57363             var declaration = signature.declaration;
57364             var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24);
57365             if (!modifiers || declaration.kind !== 166) {
57366                 return true;
57367             }
57368             var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol);
57369             var declaringClass = getDeclaredTypeOfSymbol(declaration.parent.symbol);
57370             if (!isNodeWithinClass(node, declaringClassDeclaration)) {
57371                 var containingClass = ts.getContainingClass(node);
57372                 if (containingClass && modifiers & 16) {
57373                     var containingType = getTypeOfNode(containingClass);
57374                     if (typeHasProtectedAccessibleBase(declaration.parent.symbol, containingType)) {
57375                         return true;
57376                     }
57377                 }
57378                 if (modifiers & 8) {
57379                     error(node, ts.Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass));
57380                 }
57381                 if (modifiers & 16) {
57382                     error(node, ts.Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration, typeToString(declaringClass));
57383                 }
57384                 return false;
57385             }
57386             return true;
57387         }
57388         function invocationErrorDetails(errorTarget, apparentType, kind) {
57389             var errorInfo;
57390             var isCall = kind === 0;
57391             var awaitedType = getAwaitedType(apparentType);
57392             var maybeMissingAwait = awaitedType && getSignaturesOfType(awaitedType, kind).length > 0;
57393             if (apparentType.flags & 1048576) {
57394                 var types = apparentType.types;
57395                 var hasSignatures = false;
57396                 for (var _i = 0, types_19 = types; _i < types_19.length; _i++) {
57397                     var constituent = types_19[_i];
57398                     var signatures = getSignaturesOfType(constituent, kind);
57399                     if (signatures.length !== 0) {
57400                         hasSignatures = true;
57401                         if (errorInfo) {
57402                             break;
57403                         }
57404                     }
57405                     else {
57406                         if (!errorInfo) {
57407                             errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
57408                                 ts.Diagnostics.Type_0_has_no_call_signatures :
57409                                 ts.Diagnostics.Type_0_has_no_construct_signatures, typeToString(constituent));
57410                             errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
57411                                 ts.Diagnostics.Not_all_constituents_of_type_0_are_callable :
57412                                 ts.Diagnostics.Not_all_constituents_of_type_0_are_constructable, typeToString(apparentType));
57413                         }
57414                         if (hasSignatures) {
57415                             break;
57416                         }
57417                     }
57418                 }
57419                 if (!hasSignatures) {
57420                     errorInfo = ts.chainDiagnosticMessages(undefined, isCall ?
57421                         ts.Diagnostics.No_constituent_of_type_0_is_callable :
57422                         ts.Diagnostics.No_constituent_of_type_0_is_constructable, typeToString(apparentType));
57423                 }
57424                 if (!errorInfo) {
57425                     errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
57426                         ts.Diagnostics.Each_member_of_the_union_type_0_has_signatures_but_none_of_those_signatures_are_compatible_with_each_other :
57427                         ts.Diagnostics.Each_member_of_the_union_type_0_has_construct_signatures_but_none_of_those_signatures_are_compatible_with_each_other, typeToString(apparentType));
57428                 }
57429             }
57430             else {
57431                 errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
57432                     ts.Diagnostics.Type_0_has_no_call_signatures :
57433                     ts.Diagnostics.Type_0_has_no_construct_signatures, typeToString(apparentType));
57434             }
57435             var headMessage = isCall ? ts.Diagnostics.This_expression_is_not_callable : ts.Diagnostics.This_expression_is_not_constructable;
57436             if (ts.isCallExpression(errorTarget.parent) && errorTarget.parent.arguments.length === 0) {
57437                 var resolvedSymbol = getNodeLinks(errorTarget).resolvedSymbol;
57438                 if (resolvedSymbol && resolvedSymbol.flags & 32768) {
57439                     headMessage = ts.Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without;
57440                 }
57441             }
57442             return {
57443                 messageChain: ts.chainDiagnosticMessages(errorInfo, headMessage),
57444                 relatedMessage: maybeMissingAwait ? ts.Diagnostics.Did_you_forget_to_use_await : undefined,
57445             };
57446         }
57447         function invocationError(errorTarget, apparentType, kind, relatedInformation) {
57448             var _a = invocationErrorDetails(errorTarget, apparentType, kind), messageChain = _a.messageChain, relatedInfo = _a.relatedMessage;
57449             var diagnostic = ts.createDiagnosticForNodeFromMessageChain(errorTarget, messageChain);
57450             if (relatedInfo) {
57451                 ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(errorTarget, relatedInfo));
57452             }
57453             if (ts.isCallExpression(errorTarget.parent)) {
57454                 var _b = getDiagnosticSpanForCallNode(errorTarget.parent, true), start = _b.start, length_7 = _b.length;
57455                 diagnostic.start = start;
57456                 diagnostic.length = length_7;
57457             }
57458             diagnostics.add(diagnostic);
57459             invocationErrorRecovery(apparentType, kind, relatedInformation ? ts.addRelatedInfo(diagnostic, relatedInformation) : diagnostic);
57460         }
57461         function invocationErrorRecovery(apparentType, kind, diagnostic) {
57462             if (!apparentType.symbol) {
57463                 return;
57464             }
57465             var importNode = getSymbolLinks(apparentType.symbol).originatingImport;
57466             if (importNode && !ts.isImportCall(importNode)) {
57467                 var sigs = getSignaturesOfType(getTypeOfSymbol(getSymbolLinks(apparentType.symbol).target), kind);
57468                 if (!sigs || !sigs.length)
57469                     return;
57470                 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));
57471             }
57472         }
57473         function resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode) {
57474             var tagType = checkExpression(node.tag);
57475             var apparentType = getApparentType(tagType);
57476             if (apparentType === errorType) {
57477                 return resolveErrorCall(node);
57478             }
57479             var callSignatures = getSignaturesOfType(apparentType, 0);
57480             var numConstructSignatures = getSignaturesOfType(apparentType, 1).length;
57481             if (isUntypedFunctionCall(tagType, apparentType, callSignatures.length, numConstructSignatures)) {
57482                 return resolveUntypedCall(node);
57483             }
57484             if (!callSignatures.length) {
57485                 if (ts.isArrayLiteralExpression(node.parent)) {
57486                     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);
57487                     diagnostics.add(diagnostic);
57488                     return resolveErrorCall(node);
57489                 }
57490                 invocationError(node.tag, apparentType, 0);
57491                 return resolveErrorCall(node);
57492             }
57493             return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0);
57494         }
57495         function getDiagnosticHeadMessageForDecoratorResolution(node) {
57496             switch (node.parent.kind) {
57497                 case 252:
57498                 case 221:
57499                     return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression;
57500                 case 160:
57501                     return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression;
57502                 case 163:
57503                     return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression;
57504                 case 165:
57505                 case 167:
57506                 case 168:
57507                     return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression;
57508                 default:
57509                     return ts.Debug.fail();
57510             }
57511         }
57512         function resolveDecorator(node, candidatesOutArray, checkMode) {
57513             var funcType = checkExpression(node.expression);
57514             var apparentType = getApparentType(funcType);
57515             if (apparentType === errorType) {
57516                 return resolveErrorCall(node);
57517             }
57518             var callSignatures = getSignaturesOfType(apparentType, 0);
57519             var numConstructSignatures = getSignaturesOfType(apparentType, 1).length;
57520             if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) {
57521                 return resolveUntypedCall(node);
57522             }
57523             if (isPotentiallyUncalledDecorator(node, callSignatures)) {
57524                 var nodeStr = ts.getTextOfNode(node.expression, false);
57525                 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);
57526                 return resolveErrorCall(node);
57527             }
57528             var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
57529             if (!callSignatures.length) {
57530                 var errorDetails = invocationErrorDetails(node.expression, apparentType, 0);
57531                 var messageChain = ts.chainDiagnosticMessages(errorDetails.messageChain, headMessage);
57532                 var diag = ts.createDiagnosticForNodeFromMessageChain(node.expression, messageChain);
57533                 if (errorDetails.relatedMessage) {
57534                     ts.addRelatedInfo(diag, ts.createDiagnosticForNode(node.expression, errorDetails.relatedMessage));
57535                 }
57536                 diagnostics.add(diag);
57537                 invocationErrorRecovery(apparentType, 0, diag);
57538                 return resolveErrorCall(node);
57539             }
57540             return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0, headMessage);
57541         }
57542         function createSignatureForJSXIntrinsic(node, result) {
57543             var namespace = getJsxNamespaceAt(node);
57544             var exports = namespace && getExportsOfSymbol(namespace);
57545             var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968);
57546             var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968, node);
57547             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));
57548             var parameterSymbol = createSymbol(1, "props");
57549             parameterSymbol.type = result;
57550             return createSignature(declaration, undefined, undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, undefined, 1, 0);
57551         }
57552         function resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) {
57553             if (isJsxIntrinsicIdentifier(node.tagName)) {
57554                 var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node);
57555                 var fakeSignature = createSignatureForJSXIntrinsic(node, result);
57556                 checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), undefined, 0), result, node.tagName, node.attributes);
57557                 if (ts.length(node.typeArguments)) {
57558                     ts.forEach(node.typeArguments, checkSourceElement);
57559                     diagnostics.add(ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), node.typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, 0, ts.length(node.typeArguments)));
57560                 }
57561                 return fakeSignature;
57562             }
57563             var exprTypes = checkExpression(node.tagName);
57564             var apparentType = getApparentType(exprTypes);
57565             if (apparentType === errorType) {
57566                 return resolveErrorCall(node);
57567             }
57568             var signatures = getUninstantiatedJsxSignaturesOfType(exprTypes, node);
57569             if (isUntypedFunctionCall(exprTypes, apparentType, signatures.length, 0)) {
57570                 return resolveUntypedCall(node);
57571             }
57572             if (signatures.length === 0) {
57573                 error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName));
57574                 return resolveErrorCall(node);
57575             }
57576             return resolveCall(node, signatures, candidatesOutArray, checkMode, 0);
57577         }
57578         function isPotentiallyUncalledDecorator(decorator, signatures) {
57579             return signatures.length && ts.every(signatures, function (signature) {
57580                 return signature.minArgumentCount === 0 &&
57581                     !signatureHasRestParameter(signature) &&
57582                     signature.parameters.length < getDecoratorArgumentCount(decorator, signature);
57583             });
57584         }
57585         function resolveSignature(node, candidatesOutArray, checkMode) {
57586             switch (node.kind) {
57587                 case 203:
57588                     return resolveCallExpression(node, candidatesOutArray, checkMode);
57589                 case 204:
57590                     return resolveNewExpression(node, candidatesOutArray, checkMode);
57591                 case 205:
57592                     return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode);
57593                 case 161:
57594                     return resolveDecorator(node, candidatesOutArray, checkMode);
57595                 case 275:
57596                 case 274:
57597                     return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode);
57598             }
57599             throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable.");
57600         }
57601         function getResolvedSignature(node, candidatesOutArray, checkMode) {
57602             var links = getNodeLinks(node);
57603             var cached = links.resolvedSignature;
57604             if (cached && cached !== resolvingSignature && !candidatesOutArray) {
57605                 return cached;
57606             }
57607             links.resolvedSignature = resolvingSignature;
57608             var result = resolveSignature(node, candidatesOutArray, checkMode || 0);
57609             if (result !== resolvingSignature) {
57610                 links.resolvedSignature = flowLoopStart === flowLoopCount ? result : cached;
57611             }
57612             return result;
57613         }
57614         function isJSConstructor(node) {
57615             var _a;
57616             if (!node || !ts.isInJSFile(node)) {
57617                 return false;
57618             }
57619             var func = ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) ? node :
57620                 ts.isVariableDeclaration(node) && node.initializer && ts.isFunctionExpression(node.initializer) ? node.initializer :
57621                     undefined;
57622             if (func) {
57623                 if (ts.getJSDocClassTag(node))
57624                     return true;
57625                 var symbol = getSymbolOfNode(func);
57626                 return !!((_a = symbol === null || symbol === void 0 ? void 0 : symbol.members) === null || _a === void 0 ? void 0 : _a.size);
57627             }
57628             return false;
57629         }
57630         function mergeJSSymbols(target, source) {
57631             var _a, _b;
57632             if (source) {
57633                 var links = getSymbolLinks(source);
57634                 if (!links.inferredClassSymbol || !links.inferredClassSymbol.has(getSymbolId(target))) {
57635                     var inferred = ts.isTransientSymbol(target) ? target : cloneSymbol(target);
57636                     inferred.exports = inferred.exports || ts.createSymbolTable();
57637                     inferred.members = inferred.members || ts.createSymbolTable();
57638                     inferred.flags |= source.flags & 32;
57639                     if ((_a = source.exports) === null || _a === void 0 ? void 0 : _a.size) {
57640                         mergeSymbolTable(inferred.exports, source.exports);
57641                     }
57642                     if ((_b = source.members) === null || _b === void 0 ? void 0 : _b.size) {
57643                         mergeSymbolTable(inferred.members, source.members);
57644                     }
57645                     (links.inferredClassSymbol || (links.inferredClassSymbol = new ts.Map())).set(getSymbolId(inferred), inferred);
57646                     return inferred;
57647                 }
57648                 return links.inferredClassSymbol.get(getSymbolId(target));
57649             }
57650         }
57651         function getAssignedClassSymbol(decl) {
57652             var _a;
57653             var assignmentSymbol = decl && getSymbolOfExpando(decl, true);
57654             var prototype = (_a = assignmentSymbol === null || assignmentSymbol === void 0 ? void 0 : assignmentSymbol.exports) === null || _a === void 0 ? void 0 : _a.get("prototype");
57655             var init = (prototype === null || prototype === void 0 ? void 0 : prototype.valueDeclaration) && getAssignedJSPrototype(prototype.valueDeclaration);
57656             return init ? getSymbolOfNode(init) : undefined;
57657         }
57658         function getSymbolOfExpando(node, allowDeclaration) {
57659             if (!node.parent) {
57660                 return undefined;
57661             }
57662             var name;
57663             var decl;
57664             if (ts.isVariableDeclaration(node.parent) && node.parent.initializer === node) {
57665                 if (!ts.isInJSFile(node) && !(ts.isVarConst(node.parent) && ts.isFunctionLikeDeclaration(node))) {
57666                     return undefined;
57667                 }
57668                 name = node.parent.name;
57669                 decl = node.parent;
57670             }
57671             else if (ts.isBinaryExpression(node.parent)) {
57672                 var parentNode = node.parent;
57673                 var parentNodeOperator = node.parent.operatorToken.kind;
57674                 if (parentNodeOperator === 62 && (allowDeclaration || parentNode.right === node)) {
57675                     name = parentNode.left;
57676                     decl = name;
57677                 }
57678                 else if (parentNodeOperator === 56 || parentNodeOperator === 60) {
57679                     if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) {
57680                         name = parentNode.parent.name;
57681                         decl = parentNode.parent;
57682                     }
57683                     else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 && (allowDeclaration || parentNode.parent.right === parentNode)) {
57684                         name = parentNode.parent.left;
57685                         decl = name;
57686                     }
57687                     if (!name || !ts.isBindableStaticNameExpression(name) || !ts.isSameEntityName(name, parentNode.left)) {
57688                         return undefined;
57689                     }
57690                 }
57691             }
57692             else if (allowDeclaration && ts.isFunctionDeclaration(node)) {
57693                 name = node.name;
57694                 decl = node;
57695             }
57696             if (!decl || !name || (!allowDeclaration && !ts.getExpandoInitializer(node, ts.isPrototypeAccess(name)))) {
57697                 return undefined;
57698             }
57699             return getSymbolOfNode(decl);
57700         }
57701         function getAssignedJSPrototype(node) {
57702             if (!node.parent) {
57703                 return false;
57704             }
57705             var parent = node.parent;
57706             while (parent && parent.kind === 201) {
57707                 parent = parent.parent;
57708             }
57709             if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62) {
57710                 var right = ts.getInitializerOfBinaryExpression(parent);
57711                 return ts.isObjectLiteralExpression(right) && right;
57712             }
57713         }
57714         function checkCallExpression(node, checkMode) {
57715             var _a;
57716             if (!checkGrammarTypeArguments(node, node.typeArguments))
57717                 checkGrammarArguments(node.arguments);
57718             var signature = getResolvedSignature(node, undefined, checkMode);
57719             if (signature === resolvingSignature) {
57720                 return nonInferrableType;
57721             }
57722             checkDeprecatedSignature(signature, node);
57723             if (node.expression.kind === 105) {
57724                 return voidType;
57725             }
57726             if (node.kind === 204) {
57727                 var declaration = signature.declaration;
57728                 if (declaration &&
57729                     declaration.kind !== 166 &&
57730                     declaration.kind !== 170 &&
57731                     declaration.kind !== 175 &&
57732                     !ts.isJSDocConstructSignature(declaration) &&
57733                     !isJSConstructor(declaration)) {
57734                     if (noImplicitAny) {
57735                         error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type);
57736                     }
57737                     return anyType;
57738                 }
57739             }
57740             if (ts.isInJSFile(node) && isCommonJsRequire(node)) {
57741                 return resolveExternalModuleTypeByLiteral(node.arguments[0]);
57742             }
57743             var returnType = getReturnTypeOfSignature(signature);
57744             if (returnType.flags & 12288 && isSymbolOrSymbolForCall(node)) {
57745                 return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent));
57746             }
57747             if (node.kind === 203 && node.parent.kind === 233 &&
57748                 returnType.flags & 16384 && getTypePredicateOfSignature(signature)) {
57749                 if (!ts.isDottedName(node.expression)) {
57750                     error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name);
57751                 }
57752                 else if (!getEffectsSignature(node)) {
57753                     var diagnostic = error(node.expression, ts.Diagnostics.Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation);
57754                     getTypeOfDottedName(node.expression, diagnostic);
57755                 }
57756             }
57757             if (ts.isInJSFile(node)) {
57758                 var jsSymbol = getSymbolOfExpando(node, false);
57759                 if ((_a = jsSymbol === null || jsSymbol === void 0 ? void 0 : jsSymbol.exports) === null || _a === void 0 ? void 0 : _a.size) {
57760                     var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined);
57761                     jsAssignmentType.objectFlags |= 16384;
57762                     return getIntersectionType([returnType, jsAssignmentType]);
57763                 }
57764             }
57765             return returnType;
57766         }
57767         function checkDeprecatedSignature(signature, node) {
57768             if (signature.declaration && signature.declaration.flags & 134217728) {
57769                 var suggestionNode = getDeprecatedSuggestionNode(node);
57770                 errorOrSuggestion(false, suggestionNode, ts.Diagnostics._0_is_deprecated, signatureToString(signature));
57771             }
57772         }
57773         function getDeprecatedSuggestionNode(node) {
57774             node = ts.skipParentheses(node);
57775             switch (node.kind) {
57776                 case 203:
57777                 case 161:
57778                 case 204:
57779                     return getDeprecatedSuggestionNode(node.expression);
57780                 case 205:
57781                     return getDeprecatedSuggestionNode(node.tag);
57782                 case 275:
57783                 case 274:
57784                     return getDeprecatedSuggestionNode(node.tagName);
57785                 case 202:
57786                     return node.argumentExpression;
57787                 case 201:
57788                     return node.name;
57789                 case 173:
57790                     var typeReference = node;
57791                     return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference;
57792                 default:
57793                     return node;
57794             }
57795         }
57796         function isSymbolOrSymbolForCall(node) {
57797             if (!ts.isCallExpression(node))
57798                 return false;
57799             var left = node.expression;
57800             if (ts.isPropertyAccessExpression(left) && left.name.escapedText === "for") {
57801                 left = left.expression;
57802             }
57803             if (!ts.isIdentifier(left) || left.escapedText !== "Symbol") {
57804                 return false;
57805             }
57806             var globalESSymbol = getGlobalESSymbolConstructorSymbol(false);
57807             if (!globalESSymbol) {
57808                 return false;
57809             }
57810             return globalESSymbol === resolveName(left, "Symbol", 111551, undefined, undefined, false);
57811         }
57812         function checkImportCallExpression(node) {
57813             if (!checkGrammarArguments(node.arguments))
57814                 checkGrammarImportCallExpression(node);
57815             if (node.arguments.length === 0) {
57816                 return createPromiseReturnType(node, anyType);
57817             }
57818             var specifier = node.arguments[0];
57819             var specifierType = checkExpressionCached(specifier);
57820             for (var i = 1; i < node.arguments.length; ++i) {
57821                 checkExpressionCached(node.arguments[i]);
57822             }
57823             if (specifierType.flags & 32768 || specifierType.flags & 65536 || !isTypeAssignableTo(specifierType, stringType)) {
57824                 error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType));
57825             }
57826             var moduleSymbol = resolveExternalModuleName(node, specifier);
57827             if (moduleSymbol) {
57828                 var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, true, false);
57829                 if (esModuleSymbol) {
57830                     return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol));
57831                 }
57832             }
57833             return createPromiseReturnType(node, anyType);
57834         }
57835         function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) {
57836             if (allowSyntheticDefaultImports && type && type !== errorType) {
57837                 var synthType = type;
57838                 if (!synthType.syntheticType) {
57839                     var file = ts.find(originalSymbol.declarations, ts.isSourceFile);
57840                     var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, false);
57841                     if (hasSyntheticDefault) {
57842                         var memberTable = ts.createSymbolTable();
57843                         var newSymbol = createSymbol(2097152, "default");
57844                         newSymbol.parent = originalSymbol;
57845                         newSymbol.nameType = getLiteralType("default");
57846                         newSymbol.target = resolveSymbol(symbol);
57847                         memberTable.set("default", newSymbol);
57848                         var anonymousSymbol = createSymbol(2048, "__type");
57849                         var defaultContainingObject = createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, undefined, undefined);
57850                         anonymousSymbol.type = defaultContainingObject;
57851                         synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, 0, false) : defaultContainingObject;
57852                     }
57853                     else {
57854                         synthType.syntheticType = type;
57855                     }
57856                 }
57857                 return synthType.syntheticType;
57858             }
57859             return type;
57860         }
57861         function isCommonJsRequire(node) {
57862             if (!ts.isRequireCall(node, true)) {
57863                 return false;
57864             }
57865             if (!ts.isIdentifier(node.expression))
57866                 return ts.Debug.fail();
57867             var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551, undefined, undefined, true);
57868             if (resolvedRequire === requireSymbol) {
57869                 return true;
57870             }
57871             if (resolvedRequire.flags & 2097152) {
57872                 return false;
57873             }
57874             var targetDeclarationKind = resolvedRequire.flags & 16
57875                 ? 251
57876                 : resolvedRequire.flags & 3
57877                     ? 249
57878                     : 0;
57879             if (targetDeclarationKind !== 0) {
57880                 var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind);
57881                 return !!decl && !!(decl.flags & 8388608);
57882             }
57883             return false;
57884         }
57885         function checkTaggedTemplateExpression(node) {
57886             if (!checkGrammarTaggedTemplateChain(node))
57887                 checkGrammarTypeArguments(node, node.typeArguments);
57888             if (languageVersion < 2) {
57889                 checkExternalEmitHelpers(node, 524288);
57890             }
57891             var signature = getResolvedSignature(node);
57892             checkDeprecatedSignature(signature, node);
57893             return getReturnTypeOfSignature(signature);
57894         }
57895         function checkAssertion(node) {
57896             return checkAssertionWorker(node, node.type, node.expression);
57897         }
57898         function isValidConstAssertionArgument(node) {
57899             switch (node.kind) {
57900                 case 10:
57901                 case 14:
57902                 case 8:
57903                 case 9:
57904                 case 109:
57905                 case 94:
57906                 case 199:
57907                 case 200:
57908                 case 218:
57909                     return true;
57910                 case 207:
57911                     return isValidConstAssertionArgument(node.expression);
57912                 case 214:
57913                     var op = node.operator;
57914                     var arg = node.operand;
57915                     return op === 40 && (arg.kind === 8 || arg.kind === 9) ||
57916                         op === 39 && arg.kind === 8;
57917                 case 201:
57918                 case 202:
57919                     var expr = node.expression;
57920                     if (ts.isIdentifier(expr)) {
57921                         var symbol = getSymbolAtLocation(expr);
57922                         if (symbol && symbol.flags & 2097152) {
57923                             symbol = resolveAlias(symbol);
57924                         }
57925                         return !!(symbol && (symbol.flags & 384) && getEnumKind(symbol) === 1);
57926                     }
57927             }
57928             return false;
57929         }
57930         function checkAssertionWorker(errNode, type, expression, checkMode) {
57931             var exprType = checkExpression(expression, checkMode);
57932             if (ts.isConstTypeReference(type)) {
57933                 if (!isValidConstAssertionArgument(expression)) {
57934                     error(expression, ts.Diagnostics.A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals);
57935                 }
57936                 return getRegularTypeOfLiteralType(exprType);
57937             }
57938             checkSourceElement(type);
57939             exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(exprType));
57940             var targetType = getTypeFromTypeNode(type);
57941             if (produceDiagnostics && targetType !== errorType) {
57942                 var widenedType = getWidenedType(exprType);
57943                 if (!isTypeComparableTo(targetType, widenedType)) {
57944                     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);
57945                 }
57946             }
57947             return targetType;
57948         }
57949         function checkNonNullChain(node) {
57950             var leftType = checkExpression(node.expression);
57951             var nonOptionalType = getOptionalExpressionType(leftType, node.expression);
57952             return propagateOptionalTypeMarker(getNonNullableType(nonOptionalType), node, nonOptionalType !== leftType);
57953         }
57954         function checkNonNullAssertion(node) {
57955             return node.flags & 32 ? checkNonNullChain(node) :
57956                 getNonNullableType(checkExpression(node.expression));
57957         }
57958         function checkMetaProperty(node) {
57959             checkGrammarMetaProperty(node);
57960             if (node.keywordToken === 102) {
57961                 return checkNewTargetMetaProperty(node);
57962             }
57963             if (node.keywordToken === 99) {
57964                 return checkImportMetaProperty(node);
57965             }
57966             return ts.Debug.assertNever(node.keywordToken);
57967         }
57968         function checkNewTargetMetaProperty(node) {
57969             var container = ts.getNewTargetContainer(node);
57970             if (!container) {
57971                 error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target");
57972                 return errorType;
57973             }
57974             else if (container.kind === 166) {
57975                 var symbol = getSymbolOfNode(container.parent);
57976                 return getTypeOfSymbol(symbol);
57977             }
57978             else {
57979                 var symbol = getSymbolOfNode(container);
57980                 return getTypeOfSymbol(symbol);
57981             }
57982         }
57983         function checkImportMetaProperty(node) {
57984             if (moduleKind !== ts.ModuleKind.ES2020 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) {
57985                 error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_or_system);
57986             }
57987             var file = ts.getSourceFileOfNode(node);
57988             ts.Debug.assert(!!(file.flags & 2097152), "Containing file is missing import meta node flag.");
57989             ts.Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module.");
57990             return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType;
57991         }
57992         function getTypeOfParameter(symbol) {
57993             var type = getTypeOfSymbol(symbol);
57994             if (strictNullChecks) {
57995                 var declaration = symbol.valueDeclaration;
57996                 if (declaration && ts.hasInitializer(declaration)) {
57997                     return getOptionalType(type);
57998                 }
57999             }
58000             return type;
58001         }
58002         function getTupleElementLabel(d) {
58003             ts.Debug.assert(ts.isIdentifier(d.name));
58004             return d.name.escapedText;
58005         }
58006         function getParameterNameAtPosition(signature, pos, overrideRestType) {
58007             var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
58008             if (pos < paramCount) {
58009                 return signature.parameters[pos].escapedName;
58010             }
58011             var restParameter = signature.parameters[paramCount] || unknownSymbol;
58012             var restType = overrideRestType || getTypeOfSymbol(restParameter);
58013             if (isTupleType(restType)) {
58014                 var associatedNames = restType.target.labeledElementDeclarations;
58015                 var index = pos - paramCount;
58016                 return associatedNames && getTupleElementLabel(associatedNames[index]) || restParameter.escapedName + "_" + index;
58017             }
58018             return restParameter.escapedName;
58019         }
58020         function isValidDeclarationForTupleLabel(d) {
58021             return d.kind === 192 || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name));
58022         }
58023         function getNameableDeclarationAtPosition(signature, pos) {
58024             var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
58025             if (pos < paramCount) {
58026                 var decl = signature.parameters[pos].valueDeclaration;
58027                 return decl && isValidDeclarationForTupleLabel(decl) ? decl : undefined;
58028             }
58029             var restParameter = signature.parameters[paramCount] || unknownSymbol;
58030             var restType = getTypeOfSymbol(restParameter);
58031             if (isTupleType(restType)) {
58032                 var associatedNames = restType.target.labeledElementDeclarations;
58033                 var index = pos - paramCount;
58034                 return associatedNames && associatedNames[index];
58035             }
58036             return restParameter.valueDeclaration && isValidDeclarationForTupleLabel(restParameter.valueDeclaration) ? restParameter.valueDeclaration : undefined;
58037         }
58038         function getTypeAtPosition(signature, pos) {
58039             return tryGetTypeAtPosition(signature, pos) || anyType;
58040         }
58041         function tryGetTypeAtPosition(signature, pos) {
58042             var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
58043             if (pos < paramCount) {
58044                 return getTypeOfParameter(signature.parameters[pos]);
58045             }
58046             if (signatureHasRestParameter(signature)) {
58047                 var restType = getTypeOfSymbol(signature.parameters[paramCount]);
58048                 var index = pos - paramCount;
58049                 if (!isTupleType(restType) || restType.target.hasRestElement || index < restType.target.fixedLength) {
58050                     return getIndexedAccessType(restType, getLiteralType(index));
58051                 }
58052             }
58053             return undefined;
58054         }
58055         function getRestTypeAtPosition(source, pos) {
58056             var parameterCount = getParameterCount(source);
58057             var minArgumentCount = getMinArgumentCount(source);
58058             var restType = getEffectiveRestType(source);
58059             if (restType && pos >= parameterCount - 1) {
58060                 return pos === parameterCount - 1 ? restType : createArrayType(getIndexedAccessType(restType, numberType));
58061             }
58062             var types = [];
58063             var flags = [];
58064             var names = [];
58065             for (var i = pos; i < parameterCount; i++) {
58066                 if (!restType || i < parameterCount - 1) {
58067                     types.push(getTypeAtPosition(source, i));
58068                     flags.push(i < minArgumentCount ? 1 : 2);
58069                 }
58070                 else {
58071                     types.push(restType);
58072                     flags.push(8);
58073                 }
58074                 var name = getNameableDeclarationAtPosition(source, i);
58075                 if (name) {
58076                     names.push(name);
58077                 }
58078             }
58079             return createTupleType(types, flags, false, ts.length(names) === ts.length(types) ? names : undefined);
58080         }
58081         function getParameterCount(signature) {
58082             var length = signature.parameters.length;
58083             if (signatureHasRestParameter(signature)) {
58084                 var restType = getTypeOfSymbol(signature.parameters[length - 1]);
58085                 if (isTupleType(restType)) {
58086                     return length + restType.target.fixedLength - (restType.target.hasRestElement ? 0 : 1);
58087                 }
58088             }
58089             return length;
58090         }
58091         function getMinArgumentCount(signature, flags) {
58092             var strongArityForUntypedJS = flags & 1;
58093             var voidIsNonOptional = flags & 2;
58094             if (voidIsNonOptional || signature.resolvedMinArgumentCount === undefined) {
58095                 var minArgumentCount = void 0;
58096                 if (signatureHasRestParameter(signature)) {
58097                     var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
58098                     if (isTupleType(restType)) {
58099                         var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1); });
58100                         var requiredCount = firstOptionalIndex < 0 ? restType.target.fixedLength : firstOptionalIndex;
58101                         if (requiredCount > 0) {
58102                             minArgumentCount = signature.parameters.length - 1 + requiredCount;
58103                         }
58104                     }
58105                 }
58106                 if (minArgumentCount === undefined) {
58107                     if (!strongArityForUntypedJS && signature.flags & 16) {
58108                         return 0;
58109                     }
58110                     minArgumentCount = signature.minArgumentCount;
58111                 }
58112                 if (voidIsNonOptional) {
58113                     return minArgumentCount;
58114                 }
58115                 for (var i = minArgumentCount - 1; i >= 0; i--) {
58116                     var type = getTypeAtPosition(signature, i);
58117                     if (filterType(type, acceptsVoid).flags & 131072) {
58118                         break;
58119                     }
58120                     minArgumentCount = i;
58121                 }
58122                 signature.resolvedMinArgumentCount = minArgumentCount;
58123             }
58124             return signature.resolvedMinArgumentCount;
58125         }
58126         function hasEffectiveRestParameter(signature) {
58127             if (signatureHasRestParameter(signature)) {
58128                 var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
58129                 return !isTupleType(restType) || restType.target.hasRestElement;
58130             }
58131             return false;
58132         }
58133         function getEffectiveRestType(signature) {
58134             if (signatureHasRestParameter(signature)) {
58135                 var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
58136                 if (!isTupleType(restType)) {
58137                     return restType;
58138                 }
58139                 if (restType.target.hasRestElement) {
58140                     return sliceTupleType(restType, restType.target.fixedLength);
58141                 }
58142             }
58143             return undefined;
58144         }
58145         function getNonArrayRestType(signature) {
58146             var restType = getEffectiveRestType(signature);
58147             return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072) === 0 ? restType : undefined;
58148         }
58149         function getTypeOfFirstParameterOfSignature(signature) {
58150             return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType);
58151         }
58152         function getTypeOfFirstParameterOfSignatureWithFallback(signature, fallbackType) {
58153             return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : fallbackType;
58154         }
58155         function inferFromAnnotatedParameters(signature, context, inferenceContext) {
58156             var len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
58157             for (var i = 0; i < len; i++) {
58158                 var declaration = signature.parameters[i].valueDeclaration;
58159                 if (declaration.type) {
58160                     var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
58161                     if (typeNode) {
58162                         inferTypes(inferenceContext.inferences, getTypeFromTypeNode(typeNode), getTypeAtPosition(context, i));
58163                     }
58164                 }
58165             }
58166             var restType = getEffectiveRestType(context);
58167             if (restType && restType.flags & 262144) {
58168                 var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper);
58169                 assignContextualParameterTypes(signature, instantiatedContext);
58170                 var restPos = getParameterCount(context) - 1;
58171                 inferTypes(inferenceContext.inferences, getRestTypeAtPosition(signature, restPos), restType);
58172             }
58173         }
58174         function assignContextualParameterTypes(signature, context) {
58175             signature.typeParameters = context.typeParameters;
58176             if (context.thisParameter) {
58177                 var parameter = signature.thisParameter;
58178                 if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) {
58179                     if (!parameter) {
58180                         signature.thisParameter = createSymbolWithType(context.thisParameter, undefined);
58181                     }
58182                     assignParameterType(signature.thisParameter, getTypeOfSymbol(context.thisParameter));
58183                 }
58184             }
58185             var len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
58186             for (var i = 0; i < len; i++) {
58187                 var parameter = signature.parameters[i];
58188                 if (!ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) {
58189                     var contextualParameterType = tryGetTypeAtPosition(context, i);
58190                     assignParameterType(parameter, contextualParameterType);
58191                 }
58192             }
58193             if (signatureHasRestParameter(signature)) {
58194                 var parameter = ts.last(signature.parameters);
58195                 if (ts.isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) {
58196                     var contextualParameterType = getRestTypeAtPosition(context, len);
58197                     assignParameterType(parameter, contextualParameterType);
58198                 }
58199             }
58200         }
58201         function assignNonContextualParameterTypes(signature) {
58202             if (signature.thisParameter) {
58203                 assignParameterType(signature.thisParameter);
58204             }
58205             for (var _i = 0, _a = signature.parameters; _i < _a.length; _i++) {
58206                 var parameter = _a[_i];
58207                 assignParameterType(parameter);
58208             }
58209         }
58210         function assignParameterType(parameter, type) {
58211             var links = getSymbolLinks(parameter);
58212             if (!links.type) {
58213                 var declaration = parameter.valueDeclaration;
58214                 links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, true);
58215                 if (declaration.name.kind !== 78) {
58216                     if (links.type === unknownType) {
58217                         links.type = getTypeFromBindingPattern(declaration.name);
58218                     }
58219                     assignBindingElementTypes(declaration.name);
58220                 }
58221             }
58222         }
58223         function assignBindingElementTypes(pattern) {
58224             for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
58225                 var element = _a[_i];
58226                 if (!ts.isOmittedExpression(element)) {
58227                     if (element.name.kind === 78) {
58228                         getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element);
58229                     }
58230                     else {
58231                         assignBindingElementTypes(element.name);
58232                     }
58233                 }
58234             }
58235         }
58236         function createPromiseType(promisedType) {
58237             var globalPromiseType = getGlobalPromiseType(true);
58238             if (globalPromiseType !== emptyGenericType) {
58239                 promisedType = getAwaitedType(promisedType) || unknownType;
58240                 return createTypeReference(globalPromiseType, [promisedType]);
58241             }
58242             return unknownType;
58243         }
58244         function createPromiseLikeType(promisedType) {
58245             var globalPromiseLikeType = getGlobalPromiseLikeType(true);
58246             if (globalPromiseLikeType !== emptyGenericType) {
58247                 promisedType = getAwaitedType(promisedType) || unknownType;
58248                 return createTypeReference(globalPromiseLikeType, [promisedType]);
58249             }
58250             return unknownType;
58251         }
58252         function createPromiseReturnType(func, promisedType) {
58253             var promiseType = createPromiseType(promisedType);
58254             if (promiseType === unknownType) {
58255                 error(func, ts.isImportCall(func) ?
58256                     ts.Diagnostics.A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option :
58257                     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);
58258                 return errorType;
58259             }
58260             else if (!getGlobalPromiseConstructorSymbol(true)) {
58261                 error(func, ts.isImportCall(func) ?
58262                     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 :
58263                     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);
58264             }
58265             return promiseType;
58266         }
58267         function getReturnTypeFromBody(func, checkMode) {
58268             if (!func.body) {
58269                 return errorType;
58270             }
58271             var functionFlags = ts.getFunctionFlags(func);
58272             var isAsync = (functionFlags & 2) !== 0;
58273             var isGenerator = (functionFlags & 1) !== 0;
58274             var returnType;
58275             var yieldType;
58276             var nextType;
58277             var fallbackReturnType = voidType;
58278             if (func.body.kind !== 230) {
58279                 returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8);
58280                 if (isAsync) {
58281                     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);
58282                 }
58283             }
58284             else if (isGenerator) {
58285                 var returnTypes = checkAndAggregateReturnExpressionTypes(func, checkMode);
58286                 if (!returnTypes) {
58287                     fallbackReturnType = neverType;
58288                 }
58289                 else if (returnTypes.length > 0) {
58290                     returnType = getUnionType(returnTypes, 2);
58291                 }
58292                 var _a = checkAndAggregateYieldOperandTypes(func, checkMode), yieldTypes = _a.yieldTypes, nextTypes = _a.nextTypes;
58293                 yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2) : undefined;
58294                 nextType = ts.some(nextTypes) ? getIntersectionType(nextTypes) : undefined;
58295             }
58296             else {
58297                 var types = checkAndAggregateReturnExpressionTypes(func, checkMode);
58298                 if (!types) {
58299                     return functionFlags & 2
58300                         ? createPromiseReturnType(func, neverType)
58301                         : neverType;
58302                 }
58303                 if (types.length === 0) {
58304                     return functionFlags & 2
58305                         ? createPromiseReturnType(func, voidType)
58306                         : voidType;
58307                 }
58308                 returnType = getUnionType(types, 2);
58309             }
58310             if (returnType || yieldType || nextType) {
58311                 if (yieldType)
58312                     reportErrorsFromWidening(func, yieldType, 3);
58313                 if (returnType)
58314                     reportErrorsFromWidening(func, returnType, 1);
58315                 if (nextType)
58316                     reportErrorsFromWidening(func, nextType, 2);
58317                 if (returnType && isUnitType(returnType) ||
58318                     yieldType && isUnitType(yieldType) ||
58319                     nextType && isUnitType(nextType)) {
58320                     var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func);
58321                     var contextualType = !contextualSignature ? undefined :
58322                         contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType :
58323                             instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func);
58324                     if (isGenerator) {
58325                         yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0, isAsync);
58326                         returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1, isAsync);
58327                         nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2, isAsync);
58328                     }
58329                     else {
58330                         returnType = getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(returnType, contextualType, isAsync);
58331                     }
58332                 }
58333                 if (yieldType)
58334                     yieldType = getWidenedType(yieldType);
58335                 if (returnType)
58336                     returnType = getWidenedType(returnType);
58337                 if (nextType)
58338                     nextType = getWidenedType(nextType);
58339             }
58340             if (isGenerator) {
58341                 return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2, func) || unknownType, isAsync);
58342             }
58343             else {
58344                 return isAsync
58345                     ? createPromiseType(returnType || fallbackReturnType)
58346                     : returnType || fallbackReturnType;
58347             }
58348         }
58349         function createGeneratorReturnType(yieldType, returnType, nextType, isAsyncGenerator) {
58350             var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver;
58351             var globalGeneratorType = resolver.getGlobalGeneratorType(false);
58352             yieldType = resolver.resolveIterationType(yieldType, undefined) || unknownType;
58353             returnType = resolver.resolveIterationType(returnType, undefined) || unknownType;
58354             nextType = resolver.resolveIterationType(nextType, undefined) || unknownType;
58355             if (globalGeneratorType === emptyGenericType) {
58356                 var globalType = resolver.getGlobalIterableIteratorType(false);
58357                 var iterationTypes = globalType !== emptyGenericType ? getIterationTypesOfGlobalIterableType(globalType, resolver) : undefined;
58358                 var iterableIteratorReturnType = iterationTypes ? iterationTypes.returnType : anyType;
58359                 var iterableIteratorNextType = iterationTypes ? iterationTypes.nextType : undefinedType;
58360                 if (isTypeAssignableTo(returnType, iterableIteratorReturnType) &&
58361                     isTypeAssignableTo(iterableIteratorNextType, nextType)) {
58362                     if (globalType !== emptyGenericType) {
58363                         return createTypeFromGenericGlobalType(globalType, [yieldType]);
58364                     }
58365                     resolver.getGlobalIterableIteratorType(true);
58366                     return emptyObjectType;
58367                 }
58368                 resolver.getGlobalGeneratorType(true);
58369                 return emptyObjectType;
58370             }
58371             return createTypeFromGenericGlobalType(globalGeneratorType, [yieldType, returnType, nextType]);
58372         }
58373         function checkAndAggregateYieldOperandTypes(func, checkMode) {
58374             var yieldTypes = [];
58375             var nextTypes = [];
58376             var isAsync = (ts.getFunctionFlags(func) & 2) !== 0;
58377             ts.forEachYieldExpression(func.body, function (yieldExpression) {
58378                 var yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode) : undefinedWideningType;
58379                 ts.pushIfUnique(yieldTypes, getYieldedTypeOfYieldExpression(yieldExpression, yieldExpressionType, anyType, isAsync));
58380                 var nextType;
58381                 if (yieldExpression.asteriskToken) {
58382                     var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 : 17, yieldExpression.expression);
58383                     nextType = iterationTypes && iterationTypes.nextType;
58384                 }
58385                 else {
58386                     nextType = getContextualType(yieldExpression);
58387                 }
58388                 if (nextType)
58389                     ts.pushIfUnique(nextTypes, nextType);
58390             });
58391             return { yieldTypes: yieldTypes, nextTypes: nextTypes };
58392         }
58393         function getYieldedTypeOfYieldExpression(node, expressionType, sentType, isAsync) {
58394             var errorNode = node.expression || node;
58395             var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 : 17, expressionType, sentType, errorNode) : expressionType;
58396             return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken
58397                 ? 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
58398                 : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
58399         }
58400         function getFactsFromTypeofSwitch(start, end, witnesses, hasDefault) {
58401             var facts = 0;
58402             if (hasDefault) {
58403                 for (var i = end; i < witnesses.length; i++) {
58404                     facts |= typeofNEFacts.get(witnesses[i]) || 32768;
58405                 }
58406                 for (var i = start; i < end; i++) {
58407                     facts &= ~(typeofNEFacts.get(witnesses[i]) || 0);
58408                 }
58409                 for (var i = 0; i < start; i++) {
58410                     facts |= typeofNEFacts.get(witnesses[i]) || 32768;
58411                 }
58412             }
58413             else {
58414                 for (var i = start; i < end; i++) {
58415                     facts |= typeofEQFacts.get(witnesses[i]) || 128;
58416                 }
58417                 for (var i = 0; i < start; i++) {
58418                     facts &= ~(typeofEQFacts.get(witnesses[i]) || 0);
58419                 }
58420             }
58421             return facts;
58422         }
58423         function isExhaustiveSwitchStatement(node) {
58424             var links = getNodeLinks(node);
58425             return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node));
58426         }
58427         function computeExhaustiveSwitchStatement(node) {
58428             if (node.expression.kind === 211) {
58429                 var operandType = getTypeOfExpression(node.expression.expression);
58430                 var witnesses = getSwitchClauseTypeOfWitnesses(node, false);
58431                 var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, true);
58432                 var type_4 = getBaseConstraintOfType(operandType) || operandType;
58433                 if (type_4.flags & 3) {
58434                     return (556800 & notEqualFacts_1) === 556800;
58435                 }
58436                 return !!(filterType(type_4, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072);
58437             }
58438             var type = getTypeOfExpression(node.expression);
58439             if (!isLiteralType(type)) {
58440                 return false;
58441             }
58442             var switchTypes = getSwitchClauseTypes(node);
58443             if (!switchTypes.length || ts.some(switchTypes, isNeitherUnitTypeNorNever)) {
58444                 return false;
58445             }
58446             return eachTypeContainedIn(mapType(type, getRegularTypeOfLiteralType), switchTypes);
58447         }
58448         function functionHasImplicitReturn(func) {
58449             return func.endFlowNode && isReachableFlowNode(func.endFlowNode);
58450         }
58451         function checkAndAggregateReturnExpressionTypes(func, checkMode) {
58452             var functionFlags = ts.getFunctionFlags(func);
58453             var aggregatedTypes = [];
58454             var hasReturnWithNoExpression = functionHasImplicitReturn(func);
58455             var hasReturnOfTypeNever = false;
58456             ts.forEachReturnStatement(func.body, function (returnStatement) {
58457                 var expr = returnStatement.expression;
58458                 if (expr) {
58459                     var type = checkExpressionCached(expr, checkMode && checkMode & ~8);
58460                     if (functionFlags & 2) {
58461                         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);
58462                     }
58463                     if (type.flags & 131072) {
58464                         hasReturnOfTypeNever = true;
58465                     }
58466                     ts.pushIfUnique(aggregatedTypes, type);
58467                 }
58468                 else {
58469                     hasReturnWithNoExpression = true;
58470                 }
58471             });
58472             if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || mayReturnNever(func))) {
58473                 return undefined;
58474             }
58475             if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression &&
58476                 !(isJSConstructor(func) && aggregatedTypes.some(function (t) { return t.symbol === func.symbol; }))) {
58477                 ts.pushIfUnique(aggregatedTypes, undefinedType);
58478             }
58479             return aggregatedTypes;
58480         }
58481         function mayReturnNever(func) {
58482             switch (func.kind) {
58483                 case 208:
58484                 case 209:
58485                     return true;
58486                 case 165:
58487                     return func.parent.kind === 200;
58488                 default:
58489                     return false;
58490             }
58491         }
58492         function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) {
58493             if (!produceDiagnostics) {
58494                 return;
58495             }
58496             var functionFlags = ts.getFunctionFlags(func);
58497             var type = returnType && unwrapReturnType(returnType, functionFlags);
58498             if (type && maybeTypeOfKind(type, 1 | 16384)) {
58499                 return;
58500             }
58501             if (func.kind === 164 || ts.nodeIsMissing(func.body) || func.body.kind !== 230 || !functionHasImplicitReturn(func)) {
58502                 return;
58503             }
58504             var hasExplicitReturn = func.flags & 512;
58505             if (type && type.flags & 131072) {
58506                 error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
58507             }
58508             else if (type && !hasExplicitReturn) {
58509                 error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
58510             }
58511             else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
58512                 error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
58513             }
58514             else if (compilerOptions.noImplicitReturns) {
58515                 if (!type) {
58516                     if (!hasExplicitReturn) {
58517                         return;
58518                     }
58519                     var inferredReturnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func));
58520                     if (isUnwrappedReturnTypeVoidOrAny(func, inferredReturnType)) {
58521                         return;
58522                     }
58523                 }
58524                 error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Not_all_code_paths_return_a_value);
58525             }
58526         }
58527         function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) {
58528             ts.Debug.assert(node.kind !== 165 || ts.isObjectLiteralMethod(node));
58529             checkNodeDeferred(node);
58530             if (checkMode && checkMode & 4 && isContextSensitive(node)) {
58531                 if (!ts.getEffectiveReturnTypeNode(node) && !hasContextSensitiveParameters(node)) {
58532                     var contextualSignature = getContextualSignature(node);
58533                     if (contextualSignature && couldContainTypeVariables(getReturnTypeOfSignature(contextualSignature))) {
58534                         var links = getNodeLinks(node);
58535                         if (links.contextFreeType) {
58536                             return links.contextFreeType;
58537                         }
58538                         var returnType = getReturnTypeFromBody(node, checkMode);
58539                         var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, undefined, 0, 0);
58540                         var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, undefined, undefined);
58541                         returnOnlyType.objectFlags |= 2097152;
58542                         return links.contextFreeType = returnOnlyType;
58543                     }
58544                 }
58545                 return anyFunctionType;
58546             }
58547             var hasGrammarError = checkGrammarFunctionLikeDeclaration(node);
58548             if (!hasGrammarError && node.kind === 208) {
58549                 checkGrammarForGenerator(node);
58550             }
58551             contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode);
58552             return getTypeOfSymbol(getSymbolOfNode(node));
58553         }
58554         function contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode) {
58555             var links = getNodeLinks(node);
58556             if (!(links.flags & 1024)) {
58557                 var contextualSignature = getContextualSignature(node);
58558                 if (!(links.flags & 1024)) {
58559                     links.flags |= 1024;
58560                     var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0));
58561                     if (!signature) {
58562                         return;
58563                     }
58564                     if (isContextSensitive(node)) {
58565                         if (contextualSignature) {
58566                             var inferenceContext = getInferenceContext(node);
58567                             if (checkMode && checkMode & 2) {
58568                                 inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
58569                             }
58570                             var instantiatedContextualSignature = inferenceContext ?
58571                                 instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature;
58572                             assignContextualParameterTypes(signature, instantiatedContextualSignature);
58573                         }
58574                         else {
58575                             assignNonContextualParameterTypes(signature);
58576                         }
58577                     }
58578                     if (contextualSignature && !getReturnTypeFromAnnotation(node) && !signature.resolvedReturnType) {
58579                         var returnType = getReturnTypeFromBody(node, checkMode);
58580                         if (!signature.resolvedReturnType) {
58581                             signature.resolvedReturnType = returnType;
58582                         }
58583                     }
58584                     checkSignatureDeclaration(node);
58585                 }
58586             }
58587         }
58588         function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) {
58589             ts.Debug.assert(node.kind !== 165 || ts.isObjectLiteralMethod(node));
58590             var functionFlags = ts.getFunctionFlags(node);
58591             var returnType = getReturnTypeFromAnnotation(node);
58592             checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType);
58593             if (node.body) {
58594                 if (!ts.getEffectiveReturnTypeNode(node)) {
58595                     getReturnTypeOfSignature(getSignatureFromDeclaration(node));
58596                 }
58597                 if (node.body.kind === 230) {
58598                     checkSourceElement(node.body);
58599                 }
58600                 else {
58601                     var exprType = checkExpression(node.body);
58602                     var returnOrPromisedType = returnType && unwrapReturnType(returnType, functionFlags);
58603                     if (returnOrPromisedType) {
58604                         if ((functionFlags & 3) === 2) {
58605                             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);
58606                             checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body);
58607                         }
58608                         else {
58609                             checkTypeAssignableToAndOptionallyElaborate(exprType, returnOrPromisedType, node.body, node.body);
58610                         }
58611                     }
58612                 }
58613             }
58614         }
58615         function checkArithmeticOperandType(operand, type, diagnostic, isAwaitValid) {
58616             if (isAwaitValid === void 0) { isAwaitValid = false; }
58617             if (!isTypeAssignableTo(type, numberOrBigIntType)) {
58618                 var awaitedType = isAwaitValid && getAwaitedTypeOfPromise(type);
58619                 errorAndMaybeSuggestAwait(operand, !!awaitedType && isTypeAssignableTo(awaitedType, numberOrBigIntType), diagnostic);
58620                 return false;
58621             }
58622             return true;
58623         }
58624         function isReadonlyAssignmentDeclaration(d) {
58625             if (!ts.isCallExpression(d)) {
58626                 return false;
58627             }
58628             if (!ts.isBindableObjectDefinePropertyCall(d)) {
58629                 return false;
58630             }
58631             var objectLitType = checkExpressionCached(d.arguments[2]);
58632             var valueType = getTypeOfPropertyOfType(objectLitType, "value");
58633             if (valueType) {
58634                 var writableProp = getPropertyOfType(objectLitType, "writable");
58635                 var writableType = writableProp && getTypeOfSymbol(writableProp);
58636                 if (!writableType || writableType === falseType || writableType === regularFalseType) {
58637                     return true;
58638                 }
58639                 if (writableProp && writableProp.valueDeclaration && ts.isPropertyAssignment(writableProp.valueDeclaration)) {
58640                     var initializer = writableProp.valueDeclaration.initializer;
58641                     var rawOriginalType = checkExpression(initializer);
58642                     if (rawOriginalType === falseType || rawOriginalType === regularFalseType) {
58643                         return true;
58644                     }
58645                 }
58646                 return false;
58647             }
58648             var setProp = getPropertyOfType(objectLitType, "set");
58649             return !setProp;
58650         }
58651         function isReadonlySymbol(symbol) {
58652             return !!(ts.getCheckFlags(symbol) & 8 ||
58653                 symbol.flags & 4 && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 ||
58654                 symbol.flags & 3 && getDeclarationNodeFlagsFromSymbol(symbol) & 2 ||
58655                 symbol.flags & 98304 && !(symbol.flags & 65536) ||
58656                 symbol.flags & 8 ||
58657                 ts.some(symbol.declarations, isReadonlyAssignmentDeclaration));
58658         }
58659         function isAssignmentToReadonlyEntity(expr, symbol, assignmentKind) {
58660             var _a, _b;
58661             if (assignmentKind === 0) {
58662                 return false;
58663             }
58664             if (isReadonlySymbol(symbol)) {
58665                 if (symbol.flags & 4 &&
58666                     ts.isAccessExpression(expr) &&
58667                     expr.expression.kind === 107) {
58668                     var ctor = ts.getContainingFunction(expr);
58669                     if (!(ctor && (ctor.kind === 166 || isJSConstructor(ctor)))) {
58670                         return true;
58671                     }
58672                     if (symbol.valueDeclaration) {
58673                         var isAssignmentDeclaration_1 = ts.isBinaryExpression(symbol.valueDeclaration);
58674                         var isLocalPropertyDeclaration = ctor.parent === symbol.valueDeclaration.parent;
58675                         var isLocalParameterProperty = ctor === symbol.valueDeclaration.parent;
58676                         var isLocalThisPropertyAssignment = isAssignmentDeclaration_1 && ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) === ctor.parent;
58677                         var isLocalThisPropertyAssignmentConstructorFunction = isAssignmentDeclaration_1 && ((_b = symbol.parent) === null || _b === void 0 ? void 0 : _b.valueDeclaration) === ctor;
58678                         var isWriteableSymbol = isLocalPropertyDeclaration
58679                             || isLocalParameterProperty
58680                             || isLocalThisPropertyAssignment
58681                             || isLocalThisPropertyAssignmentConstructorFunction;
58682                         return !isWriteableSymbol;
58683                     }
58684                 }
58685                 return true;
58686             }
58687             if (ts.isAccessExpression(expr)) {
58688                 var node = ts.skipParentheses(expr.expression);
58689                 if (node.kind === 78) {
58690                     var symbol_2 = getNodeLinks(node).resolvedSymbol;
58691                     if (symbol_2.flags & 2097152) {
58692                         var declaration = getDeclarationOfAliasSymbol(symbol_2);
58693                         return !!declaration && declaration.kind === 263;
58694                     }
58695                 }
58696             }
58697             return false;
58698         }
58699         function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) {
58700             var node = ts.skipOuterExpressions(expr, 6 | 1);
58701             if (node.kind !== 78 && !ts.isAccessExpression(node)) {
58702                 error(expr, invalidReferenceMessage);
58703                 return false;
58704             }
58705             if (node.flags & 32) {
58706                 error(expr, invalidOptionalChainMessage);
58707                 return false;
58708             }
58709             return true;
58710         }
58711         function checkDeleteExpression(node) {
58712             checkExpression(node.expression);
58713             var expr = ts.skipParentheses(node.expression);
58714             if (!ts.isAccessExpression(expr)) {
58715                 error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference);
58716                 return booleanType;
58717             }
58718             if (ts.isPropertyAccessExpression(expr) && ts.isPrivateIdentifier(expr.name)) {
58719                 error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_private_identifier);
58720             }
58721             var links = getNodeLinks(expr);
58722             var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol);
58723             if (symbol) {
58724                 if (isReadonlySymbol(symbol)) {
58725                     error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property);
58726                 }
58727                 checkDeleteExpressionMustBeOptional(expr, getTypeOfSymbol(symbol));
58728             }
58729             return booleanType;
58730         }
58731         function checkDeleteExpressionMustBeOptional(expr, type) {
58732             var AnyOrUnknownOrNeverFlags = 3 | 131072;
58733             if (strictNullChecks && !(type.flags & AnyOrUnknownOrNeverFlags) && !(getFalsyFlags(type) & 32768)) {
58734                 error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_optional);
58735             }
58736         }
58737         function checkTypeOfExpression(node) {
58738             checkExpression(node.expression);
58739             return typeofType;
58740         }
58741         function checkVoidExpression(node) {
58742             checkExpression(node.expression);
58743             return undefinedWideningType;
58744         }
58745         function checkAwaitExpression(node) {
58746             if (produceDiagnostics) {
58747                 if (!(node.flags & 32768)) {
58748                     if (ts.isInTopLevelContext(node)) {
58749                         var sourceFile = ts.getSourceFileOfNode(node);
58750                         if (!hasParseDiagnostics(sourceFile)) {
58751                             var span = void 0;
58752                             if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
58753                                 if (!span)
58754                                     span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
58755                                 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);
58756                                 diagnostics.add(diagnostic);
58757                             }
58758                             if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) || languageVersion < 4) {
58759                                 span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
58760                                 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);
58761                                 diagnostics.add(diagnostic);
58762                             }
58763                         }
58764                     }
58765                     else {
58766                         var sourceFile = ts.getSourceFileOfNode(node);
58767                         if (!hasParseDiagnostics(sourceFile)) {
58768                             var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
58769                             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);
58770                             var func = ts.getContainingFunction(node);
58771                             if (func && func.kind !== 166 && (ts.getFunctionFlags(func) & 2) === 0) {
58772                                 var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
58773                                 ts.addRelatedInfo(diagnostic, relatedInfo);
58774                             }
58775                             diagnostics.add(diagnostic);
58776                         }
58777                     }
58778                 }
58779                 if (isInParameterInitializerBeforeContainingFunction(node)) {
58780                     error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer);
58781                 }
58782             }
58783             var operandType = checkExpression(node.expression);
58784             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);
58785             if (awaitedType === operandType && awaitedType !== errorType && !(operandType.flags & 3)) {
58786                 addErrorOrSuggestion(false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression));
58787             }
58788             return awaitedType;
58789         }
58790         function checkPrefixUnaryExpression(node) {
58791             var operandType = checkExpression(node.operand);
58792             if (operandType === silentNeverType) {
58793                 return silentNeverType;
58794             }
58795             switch (node.operand.kind) {
58796                 case 8:
58797                     switch (node.operator) {
58798                         case 40:
58799                             return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text));
58800                         case 39:
58801                             return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text));
58802                     }
58803                     break;
58804                 case 9:
58805                     if (node.operator === 40) {
58806                         return getFreshTypeOfLiteralType(getLiteralType({
58807                             negative: true,
58808                             base10Value: ts.parsePseudoBigInt(node.operand.text)
58809                         }));
58810                     }
58811             }
58812             switch (node.operator) {
58813                 case 39:
58814                 case 40:
58815                 case 54:
58816                     checkNonNullType(operandType, node.operand);
58817                     if (maybeTypeOfKind(operandType, 12288)) {
58818                         error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator));
58819                     }
58820                     if (node.operator === 39) {
58821                         if (maybeTypeOfKind(operandType, 2112)) {
58822                             error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType)));
58823                         }
58824                         return numberType;
58825                     }
58826                     return getUnaryResultType(operandType);
58827                 case 53:
58828                     checkTruthinessExpression(node.operand);
58829                     var facts = getTypeFacts(operandType) & (4194304 | 8388608);
58830                     return facts === 4194304 ? falseType :
58831                         facts === 8388608 ? trueType :
58832                             booleanType;
58833                 case 45:
58834                 case 46:
58835                     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);
58836                     if (ok) {
58837                         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);
58838                     }
58839                     return getUnaryResultType(operandType);
58840             }
58841             return errorType;
58842         }
58843         function checkPostfixUnaryExpression(node) {
58844             var operandType = checkExpression(node.operand);
58845             if (operandType === silentNeverType) {
58846                 return silentNeverType;
58847             }
58848             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);
58849             if (ok) {
58850                 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);
58851             }
58852             return getUnaryResultType(operandType);
58853         }
58854         function getUnaryResultType(operandType) {
58855             if (maybeTypeOfKind(operandType, 2112)) {
58856                 return isTypeAssignableToKind(operandType, 3) || maybeTypeOfKind(operandType, 296)
58857                     ? numberOrBigIntType
58858                     : bigintType;
58859             }
58860             return numberType;
58861         }
58862         function maybeTypeOfKind(type, kind) {
58863             if (type.flags & kind) {
58864                 return true;
58865             }
58866             if (type.flags & 3145728) {
58867                 var types = type.types;
58868                 for (var _i = 0, types_20 = types; _i < types_20.length; _i++) {
58869                     var t = types_20[_i];
58870                     if (maybeTypeOfKind(t, kind)) {
58871                         return true;
58872                     }
58873                 }
58874             }
58875             return false;
58876         }
58877         function isTypeAssignableToKind(source, kind, strict) {
58878             if (source.flags & kind) {
58879                 return true;
58880             }
58881             if (strict && source.flags & (3 | 16384 | 32768 | 65536)) {
58882                 return false;
58883             }
58884             return !!(kind & 296) && isTypeAssignableTo(source, numberType) ||
58885                 !!(kind & 2112) && isTypeAssignableTo(source, bigintType) ||
58886                 !!(kind & 402653316) && isTypeAssignableTo(source, stringType) ||
58887                 !!(kind & 528) && isTypeAssignableTo(source, booleanType) ||
58888                 !!(kind & 16384) && isTypeAssignableTo(source, voidType) ||
58889                 !!(kind & 131072) && isTypeAssignableTo(source, neverType) ||
58890                 !!(kind & 65536) && isTypeAssignableTo(source, nullType) ||
58891                 !!(kind & 32768) && isTypeAssignableTo(source, undefinedType) ||
58892                 !!(kind & 4096) && isTypeAssignableTo(source, esSymbolType) ||
58893                 !!(kind & 67108864) && isTypeAssignableTo(source, nonPrimitiveType);
58894         }
58895         function allTypesAssignableToKind(source, kind, strict) {
58896             return source.flags & 1048576 ?
58897                 ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) :
58898                 isTypeAssignableToKind(source, kind, strict);
58899         }
58900         function isConstEnumObjectType(type) {
58901             return !!(ts.getObjectFlags(type) & 16) && !!type.symbol && isConstEnumSymbol(type.symbol);
58902         }
58903         function isConstEnumSymbol(symbol) {
58904             return (symbol.flags & 128) !== 0;
58905         }
58906         function checkInstanceOfExpression(left, right, leftType, rightType) {
58907             if (leftType === silentNeverType || rightType === silentNeverType) {
58908                 return silentNeverType;
58909             }
58910             if (!isTypeAny(leftType) &&
58911                 allTypesAssignableToKind(leftType, 131068)) {
58912                 error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
58913             }
58914             if (!(isTypeAny(rightType) || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
58915                 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);
58916             }
58917             return booleanType;
58918         }
58919         function checkInExpression(left, right, leftType, rightType) {
58920             if (leftType === silentNeverType || rightType === silentNeverType) {
58921                 return silentNeverType;
58922             }
58923             leftType = checkNonNullType(leftType, left);
58924             rightType = checkNonNullType(rightType, right);
58925             if (!(allTypesAssignableToKind(leftType, 402653316 | 296 | 12288) ||
58926                 isTypeAssignableToKind(leftType, 4194304 | 134217728 | 268435456 | 262144))) {
58927                 error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol);
58928             }
58929             if (!allTypesAssignableToKind(rightType, 67108864 | 58982400)) {
58930                 error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
58931             }
58932             return booleanType;
58933         }
58934         function checkObjectLiteralAssignment(node, sourceType, rightIsThis) {
58935             var properties = node.properties;
58936             if (strictNullChecks && properties.length === 0) {
58937                 return checkNonNullType(sourceType, node);
58938             }
58939             for (var i = 0; i < properties.length; i++) {
58940                 checkObjectLiteralDestructuringPropertyAssignment(node, sourceType, i, properties, rightIsThis);
58941             }
58942             return sourceType;
58943         }
58944         function checkObjectLiteralDestructuringPropertyAssignment(node, objectLiteralType, propertyIndex, allProperties, rightIsThis) {
58945             if (rightIsThis === void 0) { rightIsThis = false; }
58946             var properties = node.properties;
58947             var property = properties[propertyIndex];
58948             if (property.kind === 288 || property.kind === 289) {
58949                 var name = property.name;
58950                 var exprType = getLiteralTypeFromPropertyName(name);
58951                 if (isTypeUsableAsPropertyName(exprType)) {
58952                     var text = getPropertyNameFromType(exprType);
58953                     var prop = getPropertyOfType(objectLiteralType, text);
58954                     if (prop) {
58955                         markPropertyAsReferenced(prop, property, rightIsThis);
58956                         checkPropertyAccessibility(property, false, objectLiteralType, prop);
58957                     }
58958                 }
58959                 var elementType = getIndexedAccessType(objectLiteralType, exprType, undefined, name, undefined, undefined, 16);
58960                 var type = getFlowTypeOfDestructuring(property, elementType);
58961                 return checkDestructuringAssignment(property.kind === 289 ? property : property.initializer, type);
58962             }
58963             else if (property.kind === 290) {
58964                 if (propertyIndex < properties.length - 1) {
58965                     error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
58966                 }
58967                 else {
58968                     if (languageVersion < 99) {
58969                         checkExternalEmitHelpers(property, 4);
58970                     }
58971                     var nonRestNames = [];
58972                     if (allProperties) {
58973                         for (var _i = 0, allProperties_1 = allProperties; _i < allProperties_1.length; _i++) {
58974                             var otherProperty = allProperties_1[_i];
58975                             if (!ts.isSpreadAssignment(otherProperty)) {
58976                                 nonRestNames.push(otherProperty.name);
58977                             }
58978                         }
58979                     }
58980                     var type = getRestType(objectLiteralType, nonRestNames, objectLiteralType.symbol);
58981                     checkGrammarForDisallowedTrailingComma(allProperties, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
58982                     return checkDestructuringAssignment(property.expression, type);
58983                 }
58984             }
58985             else {
58986                 error(property, ts.Diagnostics.Property_assignment_expected);
58987             }
58988         }
58989         function checkArrayLiteralAssignment(node, sourceType, checkMode) {
58990             var elements = node.elements;
58991             if (languageVersion < 2 && compilerOptions.downlevelIteration) {
58992                 checkExternalEmitHelpers(node, 512);
58993             }
58994             var possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 | 128, sourceType, undefinedType, node) || errorType;
58995             var inBoundsType = compilerOptions.noUncheckedIndexedAccess ? undefined : possiblyOutOfBoundsType;
58996             for (var i = 0; i < elements.length; i++) {
58997                 var type = possiblyOutOfBoundsType;
58998                 if (node.elements[i].kind === 220) {
58999                     type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65, sourceType, undefinedType, node) || errorType);
59000                 }
59001                 checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, type, checkMode);
59002             }
59003             return sourceType;
59004         }
59005         function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) {
59006             var elements = node.elements;
59007             var element = elements[elementIndex];
59008             if (element.kind !== 222) {
59009                 if (element.kind !== 220) {
59010                     var indexType = getLiteralType(elementIndex);
59011                     if (isArrayLikeType(sourceType)) {
59012                         var accessFlags = 16 | (hasDefaultValue(element) ? 8 : 0);
59013                         var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, undefined, createSyntheticExpression(element, indexType), accessFlags) || errorType;
59014                         var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288) : elementType_2;
59015                         var type = getFlowTypeOfDestructuring(element, assignedType);
59016                         return checkDestructuringAssignment(element, type, checkMode);
59017                     }
59018                     return checkDestructuringAssignment(element, elementType, checkMode);
59019                 }
59020                 if (elementIndex < elements.length - 1) {
59021                     error(element, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
59022                 }
59023                 else {
59024                     var restExpression = element.expression;
59025                     if (restExpression.kind === 216 && restExpression.operatorToken.kind === 62) {
59026                         error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer);
59027                     }
59028                     else {
59029                         checkGrammarForDisallowedTrailingComma(node.elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
59030                         var type = everyType(sourceType, isTupleType) ?
59031                             mapType(sourceType, function (t) { return sliceTupleType(t, elementIndex); }) :
59032                             createArrayType(elementType);
59033                         return checkDestructuringAssignment(restExpression, type, checkMode);
59034                     }
59035                 }
59036             }
59037             return undefined;
59038         }
59039         function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) {
59040             var target;
59041             if (exprOrAssignment.kind === 289) {
59042                 var prop = exprOrAssignment;
59043                 if (prop.objectAssignmentInitializer) {
59044                     if (strictNullChecks &&
59045                         !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768)) {
59046                         sourceType = getTypeWithFacts(sourceType, 524288);
59047                     }
59048                     checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode);
59049                 }
59050                 target = exprOrAssignment.name;
59051             }
59052             else {
59053                 target = exprOrAssignment;
59054             }
59055             if (target.kind === 216 && target.operatorToken.kind === 62) {
59056                 checkBinaryExpression(target, checkMode);
59057                 target = target.left;
59058             }
59059             if (target.kind === 200) {
59060                 return checkObjectLiteralAssignment(target, sourceType, rightIsThis);
59061             }
59062             if (target.kind === 199) {
59063                 return checkArrayLiteralAssignment(target, sourceType, checkMode);
59064             }
59065             return checkReferenceAssignment(target, sourceType, checkMode);
59066         }
59067         function checkReferenceAssignment(target, sourceType, checkMode) {
59068             var targetType = checkExpression(target, checkMode);
59069             var error = target.parent.kind === 290 ?
59070                 ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access :
59071                 ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access;
59072             var optionalError = target.parent.kind === 290 ?
59073                 ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access :
59074                 ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access;
59075             if (checkReferenceExpression(target, error, optionalError)) {
59076                 checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target);
59077             }
59078             if (ts.isPrivateIdentifierPropertyAccessExpression(target)) {
59079                 checkExternalEmitHelpers(target.parent, 2097152);
59080             }
59081             return sourceType;
59082         }
59083         function isSideEffectFree(node) {
59084             node = ts.skipParentheses(node);
59085             switch (node.kind) {
59086                 case 78:
59087                 case 10:
59088                 case 13:
59089                 case 205:
59090                 case 218:
59091                 case 14:
59092                 case 8:
59093                 case 9:
59094                 case 109:
59095                 case 94:
59096                 case 103:
59097                 case 150:
59098                 case 208:
59099                 case 221:
59100                 case 209:
59101                 case 199:
59102                 case 200:
59103                 case 211:
59104                 case 225:
59105                 case 274:
59106                 case 273:
59107                     return true;
59108                 case 217:
59109                     return isSideEffectFree(node.whenTrue) &&
59110                         isSideEffectFree(node.whenFalse);
59111                 case 216:
59112                     if (ts.isAssignmentOperator(node.operatorToken.kind)) {
59113                         return false;
59114                     }
59115                     return isSideEffectFree(node.left) &&
59116                         isSideEffectFree(node.right);
59117                 case 214:
59118                 case 215:
59119                     switch (node.operator) {
59120                         case 53:
59121                         case 39:
59122                         case 40:
59123                         case 54:
59124                             return true;
59125                     }
59126                     return false;
59127                 case 212:
59128                 case 206:
59129                 case 224:
59130                 default:
59131                     return false;
59132             }
59133         }
59134         function isTypeEqualityComparableTo(source, target) {
59135             return (target.flags & 98304) !== 0 || isTypeComparableTo(source, target);
59136         }
59137         function checkBinaryExpression(node, checkMode) {
59138             var workStacks = {
59139                 expr: [node],
59140                 state: [0],
59141                 leftType: [undefined]
59142             };
59143             var stackIndex = 0;
59144             var lastResult;
59145             while (stackIndex >= 0) {
59146                 node = workStacks.expr[stackIndex];
59147                 switch (workStacks.state[stackIndex]) {
59148                     case 0: {
59149                         if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) {
59150                             finishInvocation(checkExpression(node.right, checkMode));
59151                             break;
59152                         }
59153                         checkGrammarNullishCoalesceWithLogicalExpression(node);
59154                         var operator = node.operatorToken.kind;
59155                         if (operator === 62 && (node.left.kind === 200 || node.left.kind === 199)) {
59156                             finishInvocation(checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 107));
59157                             break;
59158                         }
59159                         advanceState(1);
59160                         maybeCheckExpression(node.left);
59161                         break;
59162                     }
59163                     case 1: {
59164                         var leftType = lastResult;
59165                         workStacks.leftType[stackIndex] = leftType;
59166                         var operator = node.operatorToken.kind;
59167                         if (operator === 55 || operator === 56 || operator === 60) {
59168                             checkTruthinessOfType(leftType, node.left);
59169                         }
59170                         advanceState(2);
59171                         maybeCheckExpression(node.right);
59172                         break;
59173                     }
59174                     case 2: {
59175                         var leftType = workStacks.leftType[stackIndex];
59176                         var rightType = lastResult;
59177                         finishInvocation(checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, node));
59178                         break;
59179                     }
59180                     default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for checkBinaryExpression");
59181                 }
59182             }
59183             return lastResult;
59184             function finishInvocation(result) {
59185                 lastResult = result;
59186                 stackIndex--;
59187             }
59188             function advanceState(nextState) {
59189                 workStacks.state[stackIndex] = nextState;
59190             }
59191             function maybeCheckExpression(node) {
59192                 if (ts.isBinaryExpression(node)) {
59193                     stackIndex++;
59194                     workStacks.expr[stackIndex] = node;
59195                     workStacks.state[stackIndex] = 0;
59196                     workStacks.leftType[stackIndex] = undefined;
59197                 }
59198                 else {
59199                     lastResult = checkExpression(node, checkMode);
59200                 }
59201             }
59202         }
59203         function checkGrammarNullishCoalesceWithLogicalExpression(node) {
59204             var left = node.left, operatorToken = node.operatorToken, right = node.right;
59205             if (operatorToken.kind === 60) {
59206                 if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 || left.operatorToken.kind === 55)) {
59207                     grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind));
59208                 }
59209                 if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 || right.operatorToken.kind === 55)) {
59210                     grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind));
59211                 }
59212             }
59213         }
59214         function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) {
59215             var operator = operatorToken.kind;
59216             if (operator === 62 && (left.kind === 200 || left.kind === 199)) {
59217                 return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 107);
59218             }
59219             var leftType;
59220             if (operator === 55 || operator === 56 || operator === 60) {
59221                 leftType = checkTruthinessExpression(left, checkMode);
59222             }
59223             else {
59224                 leftType = checkExpression(left, checkMode);
59225             }
59226             var rightType = checkExpression(right, checkMode);
59227             return checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode);
59228         }
59229         function checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode) {
59230             var operator = operatorToken.kind;
59231             switch (operator) {
59232                 case 41:
59233                 case 42:
59234                 case 65:
59235                 case 66:
59236                 case 43:
59237                 case 67:
59238                 case 44:
59239                 case 68:
59240                 case 40:
59241                 case 64:
59242                 case 47:
59243                 case 69:
59244                 case 48:
59245                 case 70:
59246                 case 49:
59247                 case 71:
59248                 case 51:
59249                 case 73:
59250                 case 52:
59251                 case 77:
59252                 case 50:
59253                 case 72:
59254                     if (leftType === silentNeverType || rightType === silentNeverType) {
59255                         return silentNeverType;
59256                     }
59257                     leftType = checkNonNullType(leftType, left);
59258                     rightType = checkNonNullType(rightType, right);
59259                     var suggestedOperator = void 0;
59260                     if ((leftType.flags & 528) &&
59261                         (rightType.flags & 528) &&
59262                         (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) {
59263                         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));
59264                         return numberType;
59265                     }
59266                     else {
59267                         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);
59268                         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);
59269                         var resultType_1;
59270                         if ((isTypeAssignableToKind(leftType, 3) && isTypeAssignableToKind(rightType, 3)) ||
59271                             !(maybeTypeOfKind(leftType, 2112) || maybeTypeOfKind(rightType, 2112))) {
59272                             resultType_1 = numberType;
59273                         }
59274                         else if (bothAreBigIntLike(leftType, rightType)) {
59275                             switch (operator) {
59276                                 case 49:
59277                                 case 71:
59278                                     reportOperatorError();
59279                                     break;
59280                                 case 42:
59281                                 case 66:
59282                                     if (languageVersion < 3) {
59283                                         error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later);
59284                                     }
59285                             }
59286                             resultType_1 = bigintType;
59287                         }
59288                         else {
59289                             reportOperatorError(bothAreBigIntLike);
59290                             resultType_1 = errorType;
59291                         }
59292                         if (leftOk && rightOk) {
59293                             checkAssignmentOperator(resultType_1);
59294                         }
59295                         return resultType_1;
59296                     }
59297                 case 39:
59298                 case 63:
59299                     if (leftType === silentNeverType || rightType === silentNeverType) {
59300                         return silentNeverType;
59301                     }
59302                     if (!isTypeAssignableToKind(leftType, 402653316) && !isTypeAssignableToKind(rightType, 402653316)) {
59303                         leftType = checkNonNullType(leftType, left);
59304                         rightType = checkNonNullType(rightType, right);
59305                     }
59306                     var resultType = void 0;
59307                     if (isTypeAssignableToKind(leftType, 296, true) && isTypeAssignableToKind(rightType, 296, true)) {
59308                         resultType = numberType;
59309                     }
59310                     else if (isTypeAssignableToKind(leftType, 2112, true) && isTypeAssignableToKind(rightType, 2112, true)) {
59311                         resultType = bigintType;
59312                     }
59313                     else if (isTypeAssignableToKind(leftType, 402653316, true) || isTypeAssignableToKind(rightType, 402653316, true)) {
59314                         resultType = stringType;
59315                     }
59316                     else if (isTypeAny(leftType) || isTypeAny(rightType)) {
59317                         resultType = leftType === errorType || rightType === errorType ? errorType : anyType;
59318                     }
59319                     if (resultType && !checkForDisallowedESSymbolOperand(operator)) {
59320                         return resultType;
59321                     }
59322                     if (!resultType) {
59323                         var closeEnoughKind_1 = 296 | 2112 | 402653316 | 3;
59324                         reportOperatorError(function (left, right) {
59325                             return isTypeAssignableToKind(left, closeEnoughKind_1) &&
59326                                 isTypeAssignableToKind(right, closeEnoughKind_1);
59327                         });
59328                         return anyType;
59329                     }
59330                     if (operator === 63) {
59331                         checkAssignmentOperator(resultType);
59332                     }
59333                     return resultType;
59334                 case 29:
59335                 case 31:
59336                 case 32:
59337                 case 33:
59338                     if (checkForDisallowedESSymbolOperand(operator)) {
59339                         leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left));
59340                         rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right));
59341                         reportOperatorErrorUnless(function (left, right) {
59342                             return isTypeComparableTo(left, right) || isTypeComparableTo(right, left) || (isTypeAssignableTo(left, numberOrBigIntType) && isTypeAssignableTo(right, numberOrBigIntType));
59343                         });
59344                     }
59345                     return booleanType;
59346                 case 34:
59347                 case 35:
59348                 case 36:
59349                 case 37:
59350                     reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); });
59351                     return booleanType;
59352                 case 101:
59353                     return checkInstanceOfExpression(left, right, leftType, rightType);
59354                 case 100:
59355                     return checkInExpression(left, right, leftType, rightType);
59356                 case 55:
59357                 case 75: {
59358                     var resultType_2 = getTypeFacts(leftType) & 4194304 ?
59359                         getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) :
59360                         leftType;
59361                     if (operator === 75) {
59362                         checkAssignmentOperator(rightType);
59363                     }
59364                     return resultType_2;
59365                 }
59366                 case 56:
59367                 case 74: {
59368                     var resultType_3 = getTypeFacts(leftType) & 8388608 ?
59369                         getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2) :
59370                         leftType;
59371                     if (operator === 74) {
59372                         checkAssignmentOperator(rightType);
59373                     }
59374                     return resultType_3;
59375                 }
59376                 case 60:
59377                 case 76: {
59378                     var resultType_4 = getTypeFacts(leftType) & 262144 ?
59379                         getUnionType([getNonNullableType(leftType), rightType], 2) :
59380                         leftType;
59381                     if (operator === 76) {
59382                         checkAssignmentOperator(rightType);
59383                     }
59384                     return resultType_4;
59385                 }
59386                 case 62:
59387                     var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0;
59388                     checkAssignmentDeclaration(declKind, rightType);
59389                     if (isAssignmentDeclaration(declKind)) {
59390                         if (!(rightType.flags & 524288) ||
59391                             declKind !== 2 &&
59392                                 declKind !== 6 &&
59393                                 !isEmptyObjectType(rightType) &&
59394                                 !isFunctionObjectType(rightType) &&
59395                                 !(ts.getObjectFlags(rightType) & 1)) {
59396                             checkAssignmentOperator(rightType);
59397                         }
59398                         return leftType;
59399                     }
59400                     else {
59401                         checkAssignmentOperator(rightType);
59402                         return getRegularTypeOfObjectLiteral(rightType);
59403                     }
59404                 case 27:
59405                     if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) {
59406                         var sf = ts.getSourceFileOfNode(left);
59407                         var sourceText = sf.text;
59408                         var start_3 = ts.skipTrivia(sourceText, left.pos);
59409                         var isInDiag2657 = sf.parseDiagnostics.some(function (diag) {
59410                             if (diag.code !== ts.Diagnostics.JSX_expressions_must_have_one_parent_element.code)
59411                                 return false;
59412                             return ts.textSpanContainsPosition(diag, start_3);
59413                         });
59414                         if (!isInDiag2657)
59415                             error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects);
59416                     }
59417                     return rightType;
59418                 default:
59419                     return ts.Debug.fail();
59420             }
59421             function bothAreBigIntLike(left, right) {
59422                 return isTypeAssignableToKind(left, 2112) && isTypeAssignableToKind(right, 2112);
59423             }
59424             function checkAssignmentDeclaration(kind, rightType) {
59425                 if (kind === 2) {
59426                     for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) {
59427                         var prop = _a[_i];
59428                         var propType = getTypeOfSymbol(prop);
59429                         if (propType.symbol && propType.symbol.flags & 32) {
59430                             var name = prop.escapedName;
59431                             var symbol = resolveName(prop.valueDeclaration, name, 788968, undefined, name, false);
59432                             if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) {
59433                                 addDuplicateDeclarationErrorsForSymbols(symbol, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), prop);
59434                                 addDuplicateDeclarationErrorsForSymbols(prop, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), symbol);
59435                             }
59436                         }
59437                     }
59438                 }
59439             }
59440             function isEvalNode(node) {
59441                 return node.kind === 78 && node.escapedText === "eval";
59442             }
59443             function checkForDisallowedESSymbolOperand(operator) {
59444                 var offendingSymbolOperand = maybeTypeOfKind(leftType, 12288) ? left :
59445                     maybeTypeOfKind(rightType, 12288) ? right :
59446                         undefined;
59447                 if (offendingSymbolOperand) {
59448                     error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator));
59449                     return false;
59450                 }
59451                 return true;
59452             }
59453             function getSuggestedBooleanOperator(operator) {
59454                 switch (operator) {
59455                     case 51:
59456                     case 73:
59457                         return 56;
59458                     case 52:
59459                     case 77:
59460                         return 37;
59461                     case 50:
59462                     case 72:
59463                         return 55;
59464                     default:
59465                         return undefined;
59466                 }
59467             }
59468             function checkAssignmentOperator(valueType) {
59469                 if (produceDiagnostics && ts.isAssignmentOperator(operator)) {
59470                     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)
59471                         && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) {
59472                         checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right);
59473                     }
59474                 }
59475             }
59476             function isAssignmentDeclaration(kind) {
59477                 var _a;
59478                 switch (kind) {
59479                     case 2:
59480                         return true;
59481                     case 1:
59482                     case 5:
59483                     case 6:
59484                     case 3:
59485                     case 4:
59486                         var symbol = getSymbolOfNode(left);
59487                         var init = ts.getAssignedExpandoInitializer(right);
59488                         return !!init && ts.isObjectLiteralExpression(init) &&
59489                             !!((_a = symbol === null || symbol === void 0 ? void 0 : symbol.exports) === null || _a === void 0 ? void 0 : _a.size);
59490                     default:
59491                         return false;
59492                 }
59493             }
59494             function reportOperatorErrorUnless(typesAreCompatible) {
59495                 if (!typesAreCompatible(leftType, rightType)) {
59496                     reportOperatorError(typesAreCompatible);
59497                     return true;
59498                 }
59499                 return false;
59500             }
59501             function reportOperatorError(isRelated) {
59502                 var _a;
59503                 var wouldWorkWithAwait = false;
59504                 var errNode = errorNode || operatorToken;
59505                 if (isRelated) {
59506                     var awaitedLeftType = getAwaitedType(leftType);
59507                     var awaitedRightType = getAwaitedType(rightType);
59508                     wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType)
59509                         && !!(awaitedLeftType && awaitedRightType)
59510                         && isRelated(awaitedLeftType, awaitedRightType);
59511                 }
59512                 var effectiveLeft = leftType;
59513                 var effectiveRight = rightType;
59514                 if (!wouldWorkWithAwait && isRelated) {
59515                     _a = getBaseTypesIfUnrelated(leftType, rightType, isRelated), effectiveLeft = _a[0], effectiveRight = _a[1];
59516                 }
59517                 var _b = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight), leftStr = _b[0], rightStr = _b[1];
59518                 if (!tryGiveBetterPrimaryError(errNode, wouldWorkWithAwait, leftStr, rightStr)) {
59519                     errorAndMaybeSuggestAwait(errNode, wouldWorkWithAwait, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr);
59520                 }
59521             }
59522             function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) {
59523                 var typeName;
59524                 switch (operatorToken.kind) {
59525                     case 36:
59526                     case 34:
59527                         typeName = "false";
59528                         break;
59529                     case 37:
59530                     case 35:
59531                         typeName = "true";
59532                 }
59533                 if (typeName) {
59534                     return errorAndMaybeSuggestAwait(errNode, maybeMissingAwait, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, typeName, leftStr, rightStr);
59535                 }
59536                 return undefined;
59537             }
59538         }
59539         function getBaseTypesIfUnrelated(leftType, rightType, isRelated) {
59540             var effectiveLeft = leftType;
59541             var effectiveRight = rightType;
59542             var leftBase = getBaseTypeOfLiteralType(leftType);
59543             var rightBase = getBaseTypeOfLiteralType(rightType);
59544             if (!isRelated(leftBase, rightBase)) {
59545                 effectiveLeft = leftBase;
59546                 effectiveRight = rightBase;
59547             }
59548             return [effectiveLeft, effectiveRight];
59549         }
59550         function checkYieldExpression(node) {
59551             if (produceDiagnostics) {
59552                 if (!(node.flags & 8192)) {
59553                     grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body);
59554                 }
59555                 if (isInParameterInitializerBeforeContainingFunction(node)) {
59556                     error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer);
59557                 }
59558             }
59559             var func = ts.getContainingFunction(node);
59560             if (!func)
59561                 return anyType;
59562             var functionFlags = ts.getFunctionFlags(func);
59563             if (!(functionFlags & 1)) {
59564                 return anyType;
59565             }
59566             var isAsync = (functionFlags & 2) !== 0;
59567             if (node.asteriskToken) {
59568                 if (isAsync && languageVersion < 99) {
59569                     checkExternalEmitHelpers(node, 53248);
59570                 }
59571                 if (!isAsync && languageVersion < 2 && compilerOptions.downlevelIteration) {
59572                     checkExternalEmitHelpers(node, 256);
59573                 }
59574             }
59575             var returnType = getReturnTypeFromAnnotation(func);
59576             var iterationTypes = returnType && getIterationTypesOfGeneratorFunctionReturnType(returnType, isAsync);
59577             var signatureYieldType = iterationTypes && iterationTypes.yieldType || anyType;
59578             var signatureNextType = iterationTypes && iterationTypes.nextType || anyType;
59579             var resolvedSignatureNextType = isAsync ? getAwaitedType(signatureNextType) || anyType : signatureNextType;
59580             var yieldExpressionType = node.expression ? checkExpression(node.expression) : undefinedWideningType;
59581             var yieldedType = getYieldedTypeOfYieldExpression(node, yieldExpressionType, resolvedSignatureNextType, isAsync);
59582             if (returnType && yieldedType) {
59583                 checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureYieldType, node.expression || node, node.expression);
59584             }
59585             if (node.asteriskToken) {
59586                 var use = isAsync ? 19 : 17;
59587                 return getIterationTypeOfIterable(use, 1, yieldExpressionType, node.expression)
59588                     || anyType;
59589             }
59590             else if (returnType) {
59591                 return getIterationTypeOfGeneratorFunctionReturnType(2, returnType, isAsync)
59592                     || anyType;
59593             }
59594             return getContextualIterationType(2, func) || anyType;
59595         }
59596         function checkConditionalExpression(node, checkMode) {
59597             var type = checkTruthinessExpression(node.condition);
59598             checkTestingKnownTruthyCallableType(node.condition, node.whenTrue, type);
59599             var type1 = checkExpression(node.whenTrue, checkMode);
59600             var type2 = checkExpression(node.whenFalse, checkMode);
59601             return getUnionType([type1, type2], 2);
59602         }
59603         function checkTemplateExpression(node) {
59604             var texts = [node.head.text];
59605             var types = [];
59606             for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) {
59607                 var span = _a[_i];
59608                 var type = checkExpression(span.expression);
59609                 if (maybeTypeOfKind(type, 12288)) {
59610                     error(span.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String);
59611                 }
59612                 texts.push(span.literal.text);
59613                 types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType);
59614             }
59615             return isConstContext(node) ? getTemplateLiteralType(texts, types) : stringType;
59616         }
59617         function getContextNode(node) {
59618             if (node.kind === 281 && !ts.isJsxSelfClosingElement(node.parent)) {
59619                 return node.parent.parent;
59620             }
59621             return node;
59622         }
59623         function checkExpressionWithContextualType(node, contextualType, inferenceContext, checkMode) {
59624             var context = getContextNode(node);
59625             var saveContextualType = context.contextualType;
59626             var saveInferenceContext = context.inferenceContext;
59627             try {
59628                 context.contextualType = contextualType;
59629                 context.inferenceContext = inferenceContext;
59630                 var type = checkExpression(node, checkMode | 1 | (inferenceContext ? 2 : 0));
59631                 var result = maybeTypeOfKind(type, 2944) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ?
59632                     getRegularTypeOfLiteralType(type) : type;
59633                 return result;
59634             }
59635             finally {
59636                 context.contextualType = saveContextualType;
59637                 context.inferenceContext = saveInferenceContext;
59638             }
59639         }
59640         function checkExpressionCached(node, checkMode) {
59641             var links = getNodeLinks(node);
59642             if (!links.resolvedType) {
59643                 if (checkMode && checkMode !== 0) {
59644                     return checkExpression(node, checkMode);
59645                 }
59646                 var saveFlowLoopStart = flowLoopStart;
59647                 var saveFlowTypeCache = flowTypeCache;
59648                 flowLoopStart = flowLoopCount;
59649                 flowTypeCache = undefined;
59650                 links.resolvedType = checkExpression(node, checkMode);
59651                 flowTypeCache = saveFlowTypeCache;
59652                 flowLoopStart = saveFlowLoopStart;
59653             }
59654             return links.resolvedType;
59655         }
59656         function isTypeAssertion(node) {
59657             node = ts.skipParentheses(node);
59658             return node.kind === 206 || node.kind === 224;
59659         }
59660         function checkDeclarationInitializer(declaration, contextualType) {
59661             var initializer = ts.getEffectiveInitializer(declaration);
59662             var type = getQuickTypeOfExpression(initializer) ||
59663                 (contextualType ? checkExpressionWithContextualType(initializer, contextualType, undefined, 0) : checkExpressionCached(initializer));
59664             return ts.isParameter(declaration) && declaration.name.kind === 197 &&
59665                 isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ?
59666                 padTupleType(type, declaration.name) : type;
59667         }
59668         function padTupleType(type, pattern) {
59669             var patternElements = pattern.elements;
59670             var elementTypes = getTypeArguments(type).slice();
59671             var elementFlags = type.target.elementFlags.slice();
59672             for (var i = getTypeReferenceArity(type); i < patternElements.length; i++) {
59673                 var e = patternElements[i];
59674                 if (i < patternElements.length - 1 || !(e.kind === 198 && e.dotDotDotToken)) {
59675                     elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, false, false) : anyType);
59676                     elementFlags.push(2);
59677                     if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) {
59678                         reportImplicitAny(e, anyType);
59679                     }
59680                 }
59681             }
59682             return createTupleType(elementTypes, elementFlags, type.target.readonly);
59683         }
59684         function widenTypeInferredFromInitializer(declaration, type) {
59685             var widened = ts.getCombinedNodeFlags(declaration) & 2 || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type);
59686             if (ts.isInJSFile(declaration)) {
59687                 if (widened.flags & 98304) {
59688                     reportImplicitAny(declaration, anyType);
59689                     return anyType;
59690                 }
59691                 else if (isEmptyArrayLiteralType(widened)) {
59692                     reportImplicitAny(declaration, anyArrayType);
59693                     return anyArrayType;
59694                 }
59695             }
59696             return widened;
59697         }
59698         function isLiteralOfContextualType(candidateType, contextualType) {
59699             if (contextualType) {
59700                 if (contextualType.flags & 3145728) {
59701                     var types = contextualType.types;
59702                     return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); });
59703                 }
59704                 if (contextualType.flags & 58982400) {
59705                     var constraint = getBaseConstraintOfType(contextualType) || unknownType;
59706                     return maybeTypeOfKind(constraint, 4) && maybeTypeOfKind(candidateType, 128) ||
59707                         maybeTypeOfKind(constraint, 8) && maybeTypeOfKind(candidateType, 256) ||
59708                         maybeTypeOfKind(constraint, 64) && maybeTypeOfKind(candidateType, 2048) ||
59709                         maybeTypeOfKind(constraint, 4096) && maybeTypeOfKind(candidateType, 8192) ||
59710                         isLiteralOfContextualType(candidateType, constraint);
59711                 }
59712                 return !!(contextualType.flags & (128 | 4194304 | 134217728 | 268435456) && maybeTypeOfKind(candidateType, 128) ||
59713                     contextualType.flags & 256 && maybeTypeOfKind(candidateType, 256) ||
59714                     contextualType.flags & 2048 && maybeTypeOfKind(candidateType, 2048) ||
59715                     contextualType.flags & 512 && maybeTypeOfKind(candidateType, 512) ||
59716                     contextualType.flags & 8192 && maybeTypeOfKind(candidateType, 8192));
59717             }
59718             return false;
59719         }
59720         function isConstContext(node) {
59721             var parent = node.parent;
59722             return ts.isAssertionExpression(parent) && ts.isConstTypeReference(parent.type) ||
59723                 (ts.isParenthesizedExpression(parent) || ts.isArrayLiteralExpression(parent) || ts.isSpreadElement(parent)) && isConstContext(parent) ||
59724                 (ts.isPropertyAssignment(parent) || ts.isShorthandPropertyAssignment(parent) || ts.isTemplateSpan(parent)) && isConstContext(parent.parent);
59725         }
59726         function checkExpressionForMutableLocation(node, checkMode, contextualType, forceTuple) {
59727             var type = checkExpression(node, checkMode, forceTuple);
59728             return isConstContext(node) ? getRegularTypeOfLiteralType(type) :
59729                 isTypeAssertion(node) ? type :
59730                     getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node));
59731         }
59732         function checkPropertyAssignment(node, checkMode) {
59733             if (node.name.kind === 158) {
59734                 checkComputedPropertyName(node.name);
59735             }
59736             return checkExpressionForMutableLocation(node.initializer, checkMode);
59737         }
59738         function checkObjectLiteralMethod(node, checkMode) {
59739             checkGrammarMethod(node);
59740             if (node.name.kind === 158) {
59741                 checkComputedPropertyName(node.name);
59742             }
59743             var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode);
59744             return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode);
59745         }
59746         function instantiateTypeWithSingleGenericCallSignature(node, type, checkMode) {
59747             if (checkMode && checkMode & (2 | 8)) {
59748                 var callSignature = getSingleSignature(type, 0, true);
59749                 var constructSignature = getSingleSignature(type, 1, true);
59750                 var signature = callSignature || constructSignature;
59751                 if (signature && signature.typeParameters) {
59752                     var contextualType = getApparentTypeOfContextualType(node, 2);
59753                     if (contextualType) {
59754                         var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 : 1, false);
59755                         if (contextualSignature && !contextualSignature.typeParameters) {
59756                             if (checkMode & 8) {
59757                                 skippedGenericFunction(node, checkMode);
59758                                 return anyFunctionType;
59759                             }
59760                             var context = getInferenceContext(node);
59761                             var returnType = context.signature && getReturnTypeOfSignature(context.signature);
59762                             var returnSignature = returnType && getSingleCallOrConstructSignature(returnType);
59763                             if (returnSignature && !returnSignature.typeParameters && !ts.every(context.inferences, hasInferenceCandidates)) {
59764                                 var uniqueTypeParameters = getUniqueTypeParameters(context, signature.typeParameters);
59765                                 var instantiatedSignature = getSignatureInstantiationWithoutFillingInTypeArguments(signature, uniqueTypeParameters);
59766                                 var inferences_3 = ts.map(context.inferences, function (info) { return createInferenceInfo(info.typeParameter); });
59767                                 applyToParameterTypes(instantiatedSignature, contextualSignature, function (source, target) {
59768                                     inferTypes(inferences_3, source, target, 0, true);
59769                                 });
59770                                 if (ts.some(inferences_3, hasInferenceCandidates)) {
59771                                     applyToReturnTypes(instantiatedSignature, contextualSignature, function (source, target) {
59772                                         inferTypes(inferences_3, source, target);
59773                                     });
59774                                     if (!hasOverlappingInferences(context.inferences, inferences_3)) {
59775                                         mergeInferences(context.inferences, inferences_3);
59776                                         context.inferredTypeParameters = ts.concatenate(context.inferredTypeParameters, uniqueTypeParameters);
59777                                         return getOrCreateTypeFromSignature(instantiatedSignature);
59778                                     }
59779                                 }
59780                             }
59781                             return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, context));
59782                         }
59783                     }
59784                 }
59785             }
59786             return type;
59787         }
59788         function skippedGenericFunction(node, checkMode) {
59789             if (checkMode & 2) {
59790                 var context = getInferenceContext(node);
59791                 context.flags |= 4;
59792             }
59793         }
59794         function hasInferenceCandidates(info) {
59795             return !!(info.candidates || info.contraCandidates);
59796         }
59797         function hasOverlappingInferences(a, b) {
59798             for (var i = 0; i < a.length; i++) {
59799                 if (hasInferenceCandidates(a[i]) && hasInferenceCandidates(b[i])) {
59800                     return true;
59801                 }
59802             }
59803             return false;
59804         }
59805         function mergeInferences(target, source) {
59806             for (var i = 0; i < target.length; i++) {
59807                 if (!hasInferenceCandidates(target[i]) && hasInferenceCandidates(source[i])) {
59808                     target[i] = source[i];
59809                 }
59810             }
59811         }
59812         function getUniqueTypeParameters(context, typeParameters) {
59813             var result = [];
59814             var oldTypeParameters;
59815             var newTypeParameters;
59816             for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
59817                 var tp = typeParameters_2[_i];
59818                 var name = tp.symbol.escapedName;
59819                 if (hasTypeParameterByName(context.inferredTypeParameters, name) || hasTypeParameterByName(result, name)) {
59820                     var newName = getUniqueTypeParameterName(ts.concatenate(context.inferredTypeParameters, result), name);
59821                     var symbol = createSymbol(262144, newName);
59822                     var newTypeParameter = createTypeParameter(symbol);
59823                     newTypeParameter.target = tp;
59824                     oldTypeParameters = ts.append(oldTypeParameters, tp);
59825                     newTypeParameters = ts.append(newTypeParameters, newTypeParameter);
59826                     result.push(newTypeParameter);
59827                 }
59828                 else {
59829                     result.push(tp);
59830                 }
59831             }
59832             if (newTypeParameters) {
59833                 var mapper = createTypeMapper(oldTypeParameters, newTypeParameters);
59834                 for (var _a = 0, newTypeParameters_1 = newTypeParameters; _a < newTypeParameters_1.length; _a++) {
59835                     var tp = newTypeParameters_1[_a];
59836                     tp.mapper = mapper;
59837                 }
59838             }
59839             return result;
59840         }
59841         function hasTypeParameterByName(typeParameters, name) {
59842             return ts.some(typeParameters, function (tp) { return tp.symbol.escapedName === name; });
59843         }
59844         function getUniqueTypeParameterName(typeParameters, baseName) {
59845             var len = baseName.length;
59846             while (len > 1 && baseName.charCodeAt(len - 1) >= 48 && baseName.charCodeAt(len - 1) <= 57)
59847                 len--;
59848             var s = baseName.slice(0, len);
59849             for (var index = 1; true; index++) {
59850                 var augmentedName = (s + index);
59851                 if (!hasTypeParameterByName(typeParameters, augmentedName)) {
59852                     return augmentedName;
59853                 }
59854             }
59855         }
59856         function getReturnTypeOfSingleNonGenericCallSignature(funcType) {
59857             var signature = getSingleCallSignature(funcType);
59858             if (signature && !signature.typeParameters) {
59859                 return getReturnTypeOfSignature(signature);
59860             }
59861         }
59862         function getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) {
59863             var funcType = checkExpression(expr.expression);
59864             var nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
59865             var returnType = getReturnTypeOfSingleNonGenericCallSignature(funcType);
59866             return returnType && propagateOptionalTypeMarker(returnType, expr, nonOptionalType !== funcType);
59867         }
59868         function getTypeOfExpression(node) {
59869             var quickType = getQuickTypeOfExpression(node);
59870             if (quickType) {
59871                 return quickType;
59872             }
59873             if (node.flags & 67108864 && flowTypeCache) {
59874                 var cachedType = flowTypeCache[getNodeId(node)];
59875                 if (cachedType) {
59876                     return cachedType;
59877                 }
59878             }
59879             var startInvocationCount = flowInvocationCount;
59880             var type = checkExpression(node);
59881             if (flowInvocationCount !== startInvocationCount) {
59882                 var cache = flowTypeCache || (flowTypeCache = []);
59883                 cache[getNodeId(node)] = type;
59884                 ts.setNodeFlags(node, node.flags | 67108864);
59885             }
59886             return type;
59887         }
59888         function getQuickTypeOfExpression(node) {
59889             var expr = ts.skipParentheses(node);
59890             if (ts.isCallExpression(expr) && expr.expression.kind !== 105 && !ts.isRequireCall(expr, true) && !isSymbolOrSymbolForCall(expr)) {
59891                 var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) :
59892                     getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression));
59893                 if (type) {
59894                     return type;
59895                 }
59896             }
59897             else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) {
59898                 return getTypeFromTypeNode(expr.type);
59899             }
59900             else if (node.kind === 8 || node.kind === 10 ||
59901                 node.kind === 109 || node.kind === 94) {
59902                 return checkExpression(node);
59903             }
59904             return undefined;
59905         }
59906         function getContextFreeTypeOfExpression(node) {
59907             var links = getNodeLinks(node);
59908             if (links.contextFreeType) {
59909                 return links.contextFreeType;
59910             }
59911             var saveContextualType = node.contextualType;
59912             node.contextualType = anyType;
59913             try {
59914                 var type = links.contextFreeType = checkExpression(node, 4);
59915                 return type;
59916             }
59917             finally {
59918                 node.contextualType = saveContextualType;
59919             }
59920         }
59921         function checkExpression(node, checkMode, forceTuple) {
59922             ts.tracing.push("check", "checkExpression", { kind: node.kind, pos: node.pos, end: node.end });
59923             var saveCurrentNode = currentNode;
59924             currentNode = node;
59925             instantiationCount = 0;
59926             var uninstantiatedType = checkExpressionWorker(node, checkMode, forceTuple);
59927             var type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode);
59928             if (isConstEnumObjectType(type)) {
59929                 checkConstEnumAccess(node, type);
59930             }
59931             currentNode = saveCurrentNode;
59932             ts.tracing.pop();
59933             return type;
59934         }
59935         function checkConstEnumAccess(node, type) {
59936             var ok = (node.parent.kind === 201 && node.parent.expression === node) ||
59937                 (node.parent.kind === 202 && node.parent.expression === node) ||
59938                 ((node.kind === 78 || node.kind === 157) && isInRightSideOfImportOrExportAssignment(node) ||
59939                     (node.parent.kind === 176 && node.parent.exprName === node)) ||
59940                 (node.parent.kind === 270);
59941             if (!ok) {
59942                 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);
59943             }
59944             if (compilerOptions.isolatedModules) {
59945                 ts.Debug.assert(!!(type.symbol.flags & 128));
59946                 var constEnumDeclaration = type.symbol.valueDeclaration;
59947                 if (constEnumDeclaration.flags & 8388608) {
59948                     error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided);
59949                 }
59950             }
59951         }
59952         function checkParenthesizedExpression(node, checkMode) {
59953             var tag = ts.isInJSFile(node) ? ts.getJSDocTypeTag(node) : undefined;
59954             if (tag) {
59955                 return checkAssertionWorker(tag, tag.typeExpression.type, node.expression, checkMode);
59956             }
59957             return checkExpression(node.expression, checkMode);
59958         }
59959         function checkExpressionWorker(node, checkMode, forceTuple) {
59960             var kind = node.kind;
59961             if (cancellationToken) {
59962                 switch (kind) {
59963                     case 221:
59964                     case 208:
59965                     case 209:
59966                         cancellationToken.throwIfCancellationRequested();
59967                 }
59968             }
59969             switch (kind) {
59970                 case 78:
59971                     return checkIdentifier(node);
59972                 case 107:
59973                     return checkThisExpression(node);
59974                 case 105:
59975                     return checkSuperExpression(node);
59976                 case 103:
59977                     return nullWideningType;
59978                 case 14:
59979                 case 10:
59980                     return getFreshTypeOfLiteralType(getLiteralType(node.text));
59981                 case 8:
59982                     checkGrammarNumericLiteral(node);
59983                     return getFreshTypeOfLiteralType(getLiteralType(+node.text));
59984                 case 9:
59985                     checkGrammarBigIntLiteral(node);
59986                     return getFreshTypeOfLiteralType(getBigIntLiteralType(node));
59987                 case 109:
59988                     return trueType;
59989                 case 94:
59990                     return falseType;
59991                 case 218:
59992                     return checkTemplateExpression(node);
59993                 case 13:
59994                     return globalRegExpType;
59995                 case 199:
59996                     return checkArrayLiteral(node, checkMode, forceTuple);
59997                 case 200:
59998                     return checkObjectLiteral(node, checkMode);
59999                 case 201:
60000                     return checkPropertyAccessExpression(node);
60001                 case 157:
60002                     return checkQualifiedName(node);
60003                 case 202:
60004                     return checkIndexedAccess(node);
60005                 case 203:
60006                     if (node.expression.kind === 99) {
60007                         return checkImportCallExpression(node);
60008                     }
60009                 case 204:
60010                     return checkCallExpression(node, checkMode);
60011                 case 205:
60012                     return checkTaggedTemplateExpression(node);
60013                 case 207:
60014                     return checkParenthesizedExpression(node, checkMode);
60015                 case 221:
60016                     return checkClassExpression(node);
60017                 case 208:
60018                 case 209:
60019                     return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode);
60020                 case 211:
60021                     return checkTypeOfExpression(node);
60022                 case 206:
60023                 case 224:
60024                     return checkAssertion(node);
60025                 case 225:
60026                     return checkNonNullAssertion(node);
60027                 case 226:
60028                     return checkMetaProperty(node);
60029                 case 210:
60030                     return checkDeleteExpression(node);
60031                 case 212:
60032                     return checkVoidExpression(node);
60033                 case 213:
60034                     return checkAwaitExpression(node);
60035                 case 214:
60036                     return checkPrefixUnaryExpression(node);
60037                 case 215:
60038                     return checkPostfixUnaryExpression(node);
60039                 case 216:
60040                     return checkBinaryExpression(node, checkMode);
60041                 case 217:
60042                     return checkConditionalExpression(node, checkMode);
60043                 case 220:
60044                     return checkSpreadExpression(node, checkMode);
60045                 case 222:
60046                     return undefinedWideningType;
60047                 case 219:
60048                     return checkYieldExpression(node);
60049                 case 227:
60050                     return checkSyntheticExpression(node);
60051                 case 283:
60052                     return checkJsxExpression(node, checkMode);
60053                 case 273:
60054                     return checkJsxElement(node, checkMode);
60055                 case 274:
60056                     return checkJsxSelfClosingElement(node, checkMode);
60057                 case 277:
60058                     return checkJsxFragment(node);
60059                 case 281:
60060                     return checkJsxAttributes(node, checkMode);
60061                 case 275:
60062                     ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement");
60063             }
60064             return errorType;
60065         }
60066         function checkTypeParameter(node) {
60067             if (node.expression) {
60068                 grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected);
60069             }
60070             checkSourceElement(node.constraint);
60071             checkSourceElement(node.default);
60072             var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node));
60073             getBaseConstraintOfType(typeParameter);
60074             if (!hasNonCircularTypeParameterDefault(typeParameter)) {
60075                 error(node.default, ts.Diagnostics.Type_parameter_0_has_a_circular_default, typeToString(typeParameter));
60076             }
60077             var constraintType = getConstraintOfTypeParameter(typeParameter);
60078             var defaultType = getDefaultFromTypeParameter(typeParameter);
60079             if (constraintType && defaultType) {
60080                 checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
60081             }
60082             if (produceDiagnostics) {
60083                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0);
60084             }
60085         }
60086         function checkParameter(node) {
60087             checkGrammarDecoratorsAndModifiers(node);
60088             checkVariableLikeDeclaration(node);
60089             var func = ts.getContainingFunction(node);
60090             if (ts.hasSyntacticModifier(node, 92)) {
60091                 if (!(func.kind === 166 && ts.nodeIsPresent(func.body))) {
60092                     error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation);
60093                 }
60094                 if (func.kind === 166 && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") {
60095                     error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name);
60096                 }
60097             }
60098             if (node.questionToken && ts.isBindingPattern(node.name) && func.body) {
60099                 error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature);
60100             }
60101             if (node.name && ts.isIdentifier(node.name) && (node.name.escapedText === "this" || node.name.escapedText === "new")) {
60102                 if (func.parameters.indexOf(node) !== 0) {
60103                     error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText);
60104                 }
60105                 if (func.kind === 166 || func.kind === 170 || func.kind === 175) {
60106                     error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter);
60107                 }
60108                 if (func.kind === 209) {
60109                     error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter);
60110                 }
60111                 if (func.kind === 167 || func.kind === 168) {
60112                     error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters);
60113                 }
60114             }
60115             if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isTypeAssignableTo(getReducedType(getTypeOfSymbol(node.symbol)), anyReadonlyArrayType)) {
60116                 error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type);
60117             }
60118         }
60119         function checkTypePredicate(node) {
60120             var parent = getTypePredicateParent(node);
60121             if (!parent) {
60122                 error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods);
60123                 return;
60124             }
60125             var signature = getSignatureFromDeclaration(parent);
60126             var typePredicate = getTypePredicateOfSignature(signature);
60127             if (!typePredicate) {
60128                 return;
60129             }
60130             checkSourceElement(node.type);
60131             var parameterName = node.parameterName;
60132             if (typePredicate.kind === 0 || typePredicate.kind === 2) {
60133                 getTypeFromThisTypeNode(parameterName);
60134             }
60135             else {
60136                 if (typePredicate.parameterIndex >= 0) {
60137                     if (signatureHasRestParameter(signature) && typePredicate.parameterIndex === signature.parameters.length - 1) {
60138                         error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter);
60139                     }
60140                     else {
60141                         if (typePredicate.type) {
60142                             var leadingError = function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); };
60143                             checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, undefined, leadingError);
60144                         }
60145                     }
60146                 }
60147                 else if (parameterName) {
60148                     var hasReportedError = false;
60149                     for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) {
60150                         var name = _a[_i].name;
60151                         if (ts.isBindingPattern(name) &&
60152                             checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, parameterName, typePredicate.parameterName)) {
60153                             hasReportedError = true;
60154                             break;
60155                         }
60156                     }
60157                     if (!hasReportedError) {
60158                         error(node.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName);
60159                     }
60160                 }
60161             }
60162         }
60163         function getTypePredicateParent(node) {
60164             switch (node.parent.kind) {
60165                 case 209:
60166                 case 169:
60167                 case 251:
60168                 case 208:
60169                 case 174:
60170                 case 165:
60171                 case 164:
60172                     var parent = node.parent;
60173                     if (node === parent.type) {
60174                         return parent;
60175                     }
60176             }
60177         }
60178         function checkIfTypePredicateVariableIsDeclaredInBindingPattern(pattern, predicateVariableNode, predicateVariableName) {
60179             for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
60180                 var element = _a[_i];
60181                 if (ts.isOmittedExpression(element)) {
60182                     continue;
60183                 }
60184                 var name = element.name;
60185                 if (name.kind === 78 && name.escapedText === predicateVariableName) {
60186                     error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName);
60187                     return true;
60188                 }
60189                 else if (name.kind === 197 || name.kind === 196) {
60190                     if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) {
60191                         return true;
60192                     }
60193                 }
60194             }
60195         }
60196         function checkSignatureDeclaration(node) {
60197             if (node.kind === 171) {
60198                 checkGrammarIndexSignature(node);
60199             }
60200             else if (node.kind === 174 || node.kind === 251 || node.kind === 175 ||
60201                 node.kind === 169 || node.kind === 166 ||
60202                 node.kind === 170) {
60203                 checkGrammarFunctionLikeDeclaration(node);
60204             }
60205             var functionFlags = ts.getFunctionFlags(node);
60206             if (!(functionFlags & 4)) {
60207                 if ((functionFlags & 3) === 3 && languageVersion < 99) {
60208                     checkExternalEmitHelpers(node, 12288);
60209                 }
60210                 if ((functionFlags & 3) === 2 && languageVersion < 4) {
60211                     checkExternalEmitHelpers(node, 64);
60212                 }
60213                 if ((functionFlags & 3) !== 0 && languageVersion < 2) {
60214                     checkExternalEmitHelpers(node, 128);
60215                 }
60216             }
60217             checkTypeParameters(node.typeParameters);
60218             ts.forEach(node.parameters, checkParameter);
60219             if (node.type) {
60220                 checkSourceElement(node.type);
60221             }
60222             if (produceDiagnostics) {
60223                 checkCollisionWithArgumentsInGeneratedCode(node);
60224                 var returnTypeNode = ts.getEffectiveReturnTypeNode(node);
60225                 if (noImplicitAny && !returnTypeNode) {
60226                     switch (node.kind) {
60227                         case 170:
60228                             error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
60229                             break;
60230                         case 169:
60231                             error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
60232                             break;
60233                     }
60234                 }
60235                 if (returnTypeNode) {
60236                     var functionFlags_1 = ts.getFunctionFlags(node);
60237                     if ((functionFlags_1 & (4 | 1)) === 1) {
60238                         var returnType = getTypeFromTypeNode(returnTypeNode);
60239                         if (returnType === voidType) {
60240                             error(returnTypeNode, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation);
60241                         }
60242                         else {
60243                             var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0, returnType, (functionFlags_1 & 2) !== 0) || anyType;
60244                             var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1, returnType, (functionFlags_1 & 2) !== 0) || generatorYieldType;
60245                             var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2, returnType, (functionFlags_1 & 2) !== 0) || unknownType;
60246                             var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2));
60247                             checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeNode);
60248                         }
60249                     }
60250                     else if ((functionFlags_1 & 3) === 2) {
60251                         checkAsyncFunctionReturnType(node, returnTypeNode);
60252                     }
60253                 }
60254                 if (node.kind !== 171 && node.kind !== 308) {
60255                     registerForUnusedIdentifiersCheck(node);
60256                 }
60257             }
60258         }
60259         function checkClassForDuplicateDeclarations(node) {
60260             var instanceNames = new ts.Map();
60261             var staticNames = new ts.Map();
60262             var privateIdentifiers = new ts.Map();
60263             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
60264                 var member = _a[_i];
60265                 if (member.kind === 166) {
60266                     for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) {
60267                         var param = _c[_b];
60268                         if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) {
60269                             addName(instanceNames, param.name, param.name.escapedText, 3);
60270                         }
60271                     }
60272                 }
60273                 else {
60274                     var isStatic = ts.hasSyntacticModifier(member, 32);
60275                     var name = member.name;
60276                     if (!name) {
60277                         return;
60278                     }
60279                     var names = ts.isPrivateIdentifier(name) ? privateIdentifiers :
60280                         isStatic ? staticNames :
60281                             instanceNames;
60282                     var memberName = name && ts.getPropertyNameForPropertyNameNode(name);
60283                     if (memberName) {
60284                         switch (member.kind) {
60285                             case 167:
60286                                 addName(names, name, memberName, 1);
60287                                 break;
60288                             case 168:
60289                                 addName(names, name, memberName, 2);
60290                                 break;
60291                             case 163:
60292                                 addName(names, name, memberName, 3);
60293                                 break;
60294                             case 165:
60295                                 addName(names, name, memberName, 8);
60296                                 break;
60297                         }
60298                     }
60299                 }
60300             }
60301             function addName(names, location, name, meaning) {
60302                 var prev = names.get(name);
60303                 if (prev) {
60304                     if (prev & 8) {
60305                         if (meaning !== 8) {
60306                             error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location));
60307                         }
60308                     }
60309                     else if (prev & meaning) {
60310                         error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location));
60311                     }
60312                     else {
60313                         names.set(name, prev | meaning);
60314                     }
60315                 }
60316                 else {
60317                     names.set(name, meaning);
60318                 }
60319             }
60320         }
60321         function checkClassForStaticPropertyNameConflicts(node) {
60322             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
60323                 var member = _a[_i];
60324                 var memberNameNode = member.name;
60325                 var isStatic = ts.hasSyntacticModifier(member, 32);
60326                 if (isStatic && memberNameNode) {
60327                     var memberName = ts.getPropertyNameForPropertyNameNode(memberNameNode);
60328                     switch (memberName) {
60329                         case "name":
60330                         case "length":
60331                         case "caller":
60332                         case "arguments":
60333                         case "prototype":
60334                             var message = ts.Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1;
60335                             var className = getNameOfSymbolAsWritten(getSymbolOfNode(node));
60336                             error(memberNameNode, message, memberName, className);
60337                             break;
60338                     }
60339                 }
60340             }
60341         }
60342         function checkObjectTypeForDuplicateDeclarations(node) {
60343             var names = new ts.Map();
60344             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
60345                 var member = _a[_i];
60346                 if (member.kind === 162) {
60347                     var memberName = void 0;
60348                     var name = member.name;
60349                     switch (name.kind) {
60350                         case 10:
60351                         case 8:
60352                             memberName = name.text;
60353                             break;
60354                         case 78:
60355                             memberName = ts.idText(name);
60356                             break;
60357                         default:
60358                             continue;
60359                     }
60360                     if (names.get(memberName)) {
60361                         error(ts.getNameOfDeclaration(member.symbol.valueDeclaration), ts.Diagnostics.Duplicate_identifier_0, memberName);
60362                         error(member.name, ts.Diagnostics.Duplicate_identifier_0, memberName);
60363                     }
60364                     else {
60365                         names.set(memberName, true);
60366                     }
60367                 }
60368             }
60369         }
60370         function checkTypeForDuplicateIndexSignatures(node) {
60371             if (node.kind === 253) {
60372                 var nodeSymbol = getSymbolOfNode(node);
60373                 if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) {
60374                     return;
60375                 }
60376             }
60377             var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
60378             if (indexSymbol) {
60379                 var seenNumericIndexer = false;
60380                 var seenStringIndexer = false;
60381                 for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
60382                     var decl = _a[_i];
60383                     var declaration = decl;
60384                     if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
60385                         switch (declaration.parameters[0].type.kind) {
60386                             case 147:
60387                                 if (!seenStringIndexer) {
60388                                     seenStringIndexer = true;
60389                                 }
60390                                 else {
60391                                     error(declaration, ts.Diagnostics.Duplicate_string_index_signature);
60392                                 }
60393                                 break;
60394                             case 144:
60395                                 if (!seenNumericIndexer) {
60396                                     seenNumericIndexer = true;
60397                                 }
60398                                 else {
60399                                     error(declaration, ts.Diagnostics.Duplicate_number_index_signature);
60400                                 }
60401                                 break;
60402                         }
60403                     }
60404                 }
60405             }
60406         }
60407         function checkPropertyDeclaration(node) {
60408             if (!checkGrammarDecoratorsAndModifiers(node) && !checkGrammarProperty(node))
60409                 checkGrammarComputedPropertyName(node.name);
60410             checkVariableLikeDeclaration(node);
60411             if (ts.isPrivateIdentifier(node.name) && languageVersion < 99) {
60412                 for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) {
60413                     getNodeLinks(lexicalScope).flags |= 67108864;
60414                 }
60415             }
60416         }
60417         function checkPropertySignature(node) {
60418             if (ts.isPrivateIdentifier(node.name)) {
60419                 error(node, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
60420             }
60421             return checkPropertyDeclaration(node);
60422         }
60423         function checkMethodDeclaration(node) {
60424             if (!checkGrammarMethod(node))
60425                 checkGrammarComputedPropertyName(node.name);
60426             if (ts.isPrivateIdentifier(node.name)) {
60427                 error(node, ts.Diagnostics.A_method_cannot_be_named_with_a_private_identifier);
60428             }
60429             checkFunctionOrMethodDeclaration(node);
60430             if (ts.hasSyntacticModifier(node, 128) && node.kind === 165 && node.body) {
60431                 error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name));
60432             }
60433         }
60434         function checkConstructorDeclaration(node) {
60435             checkSignatureDeclaration(node);
60436             if (!checkGrammarConstructorTypeParameters(node))
60437                 checkGrammarConstructorTypeAnnotation(node);
60438             checkSourceElement(node.body);
60439             var symbol = getSymbolOfNode(node);
60440             var firstDeclaration = ts.getDeclarationOfKind(symbol, node.kind);
60441             if (node === firstDeclaration) {
60442                 checkFunctionOrConstructorSymbol(symbol);
60443             }
60444             if (ts.nodeIsMissing(node.body)) {
60445                 return;
60446             }
60447             if (!produceDiagnostics) {
60448                 return;
60449             }
60450             function isInstancePropertyWithInitializerOrPrivateIdentifierProperty(n) {
60451                 if (ts.isPrivateIdentifierPropertyDeclaration(n)) {
60452                     return true;
60453                 }
60454                 return n.kind === 163 &&
60455                     !ts.hasSyntacticModifier(n, 32) &&
60456                     !!n.initializer;
60457             }
60458             var containingClassDecl = node.parent;
60459             if (ts.getClassExtendsHeritageElement(containingClassDecl)) {
60460                 captureLexicalThis(node.parent, containingClassDecl);
60461                 var classExtendsNull = classDeclarationExtendsNull(containingClassDecl);
60462                 var superCall = findFirstSuperCall(node.body);
60463                 if (superCall) {
60464                     if (classExtendsNull) {
60465                         error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
60466                     }
60467                     var superCallShouldBeFirst = (compilerOptions.target !== 99 || !compilerOptions.useDefineForClassFields) &&
60468                         (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
60469                             ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 92); }));
60470                     if (superCallShouldBeFirst) {
60471                         var statements = node.body.statements;
60472                         var superCallStatement = void 0;
60473                         for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) {
60474                             var statement = statements_4[_i];
60475                             if (statement.kind === 233 && ts.isSuperCall(statement.expression)) {
60476                                 superCallStatement = statement;
60477                                 break;
60478                             }
60479                             if (!ts.isPrologueDirective(statement)) {
60480                                 break;
60481                             }
60482                         }
60483                         if (!superCallStatement) {
60484                             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);
60485                         }
60486                     }
60487                 }
60488                 else if (!classExtendsNull) {
60489                     error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call);
60490                 }
60491             }
60492         }
60493         function checkAccessorDeclaration(node) {
60494             if (produceDiagnostics) {
60495                 if (!checkGrammarFunctionLikeDeclaration(node) && !checkGrammarAccessor(node))
60496                     checkGrammarComputedPropertyName(node.name);
60497                 checkDecorators(node);
60498                 checkSignatureDeclaration(node);
60499                 if (node.kind === 167) {
60500                     if (!(node.flags & 8388608) && ts.nodeIsPresent(node.body) && (node.flags & 256)) {
60501                         if (!(node.flags & 512)) {
60502                             error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value);
60503                         }
60504                     }
60505                 }
60506                 if (node.name.kind === 158) {
60507                     checkComputedPropertyName(node.name);
60508                 }
60509                 if (ts.isPrivateIdentifier(node.name)) {
60510                     error(node.name, ts.Diagnostics.An_accessor_cannot_be_named_with_a_private_identifier);
60511                 }
60512                 if (!hasNonBindableDynamicName(node)) {
60513                     var otherKind = node.kind === 167 ? 168 : 167;
60514                     var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind);
60515                     if (otherAccessor) {
60516                         var nodeFlags = ts.getEffectiveModifierFlags(node);
60517                         var otherFlags = ts.getEffectiveModifierFlags(otherAccessor);
60518                         if ((nodeFlags & 28) !== (otherFlags & 28)) {
60519                             error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility);
60520                         }
60521                         if ((nodeFlags & 128) !== (otherFlags & 128)) {
60522                             error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract);
60523                         }
60524                         checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type);
60525                         checkAccessorDeclarationTypesIdentical(node, otherAccessor, getThisTypeOfDeclaration, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type);
60526                     }
60527                 }
60528                 var returnType = getTypeOfAccessors(getSymbolOfNode(node));
60529                 if (node.kind === 167) {
60530                     checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType);
60531                 }
60532             }
60533             checkSourceElement(node.body);
60534         }
60535         function checkAccessorDeclarationTypesIdentical(first, second, getAnnotatedType, message) {
60536             var firstType = getAnnotatedType(first);
60537             var secondType = getAnnotatedType(second);
60538             if (firstType && secondType && !isTypeIdenticalTo(firstType, secondType)) {
60539                 error(first, message);
60540             }
60541         }
60542         function checkMissingDeclaration(node) {
60543             checkDecorators(node);
60544         }
60545         function getEffectiveTypeArguments(node, typeParameters) {
60546             return fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(node));
60547         }
60548         function checkTypeArgumentConstraints(node, typeParameters) {
60549             var typeArguments;
60550             var mapper;
60551             var result = true;
60552             for (var i = 0; i < typeParameters.length; i++) {
60553                 var constraint = getConstraintOfTypeParameter(typeParameters[i]);
60554                 if (constraint) {
60555                     if (!typeArguments) {
60556                         typeArguments = getEffectiveTypeArguments(node, typeParameters);
60557                         mapper = createTypeMapper(typeParameters, typeArguments);
60558                     }
60559                     result = result && checkTypeAssignableTo(typeArguments[i], instantiateType(constraint, mapper), node.typeArguments[i], ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
60560                 }
60561             }
60562             return result;
60563         }
60564         function getTypeParametersForTypeReference(node) {
60565             var type = getTypeFromTypeReference(node);
60566             if (type !== errorType) {
60567                 var symbol = getNodeLinks(node).resolvedSymbol;
60568                 if (symbol) {
60569                     return symbol.flags & 524288 && getSymbolLinks(symbol).typeParameters ||
60570                         (ts.getObjectFlags(type) & 4 ? type.target.localTypeParameters : undefined);
60571                 }
60572             }
60573             return undefined;
60574         }
60575         function checkTypeReferenceNode(node) {
60576             checkGrammarTypeArguments(node, node.typeArguments);
60577             if (node.kind === 173 && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) {
60578                 grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments);
60579             }
60580             ts.forEach(node.typeArguments, checkSourceElement);
60581             var type = getTypeFromTypeReference(node);
60582             if (type !== errorType) {
60583                 if (node.typeArguments && produceDiagnostics) {
60584                     var typeParameters = getTypeParametersForTypeReference(node);
60585                     if (typeParameters) {
60586                         checkTypeArgumentConstraints(node, typeParameters);
60587                     }
60588                 }
60589                 var symbol = getNodeLinks(node).resolvedSymbol;
60590                 if (symbol) {
60591                     if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 134217728); })) {
60592                         errorOrSuggestion(false, getDeprecatedSuggestionNode(node), ts.Diagnostics._0_is_deprecated, symbol.escapedName);
60593                     }
60594                     if (type.flags & 32 && symbol.flags & 8) {
60595                         error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type));
60596                     }
60597                 }
60598             }
60599         }
60600         function getTypeArgumentConstraint(node) {
60601             var typeReferenceNode = ts.tryCast(node.parent, ts.isTypeReferenceType);
60602             if (!typeReferenceNode)
60603                 return undefined;
60604             var typeParameters = getTypeParametersForTypeReference(typeReferenceNode);
60605             var constraint = getConstraintOfTypeParameter(typeParameters[typeReferenceNode.typeArguments.indexOf(node)]);
60606             return constraint && instantiateType(constraint, createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReferenceNode, typeParameters)));
60607         }
60608         function checkTypeQuery(node) {
60609             getTypeFromTypeQueryNode(node);
60610         }
60611         function checkTypeLiteral(node) {
60612             ts.forEach(node.members, checkSourceElement);
60613             if (produceDiagnostics) {
60614                 var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
60615                 checkIndexConstraints(type);
60616                 checkTypeForDuplicateIndexSignatures(node);
60617                 checkObjectTypeForDuplicateDeclarations(node);
60618             }
60619         }
60620         function checkArrayType(node) {
60621             checkSourceElement(node.elementType);
60622         }
60623         function checkTupleType(node) {
60624             var elementTypes = node.elements;
60625             var seenOptionalElement = false;
60626             var seenRestElement = false;
60627             var hasNamedElement = ts.some(elementTypes, ts.isNamedTupleMember);
60628             for (var i = 0; i < elementTypes.length; i++) {
60629                 var e = elementTypes[i];
60630                 if (e.kind !== 192 && hasNamedElement) {
60631                     grammarErrorOnNode(e, ts.Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names);
60632                     break;
60633                 }
60634                 var flags = getTupleElementFlags(e);
60635                 if (flags & 8) {
60636                     var type = getTypeFromTypeNode(e.type);
60637                     if (!isArrayLikeType(type)) {
60638                         error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type);
60639                         break;
60640                     }
60641                     if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4) {
60642                         seenRestElement = true;
60643                     }
60644                 }
60645                 else if (flags & 4) {
60646                     seenRestElement = true;
60647                 }
60648                 else if (flags & 2) {
60649                     seenOptionalElement = true;
60650                 }
60651                 else if (seenOptionalElement) {
60652                     grammarErrorOnNode(e, ts.Diagnostics.A_required_element_cannot_follow_an_optional_element);
60653                     break;
60654                 }
60655                 if (seenRestElement && i !== elementTypes.length - 1) {
60656                     grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type);
60657                     break;
60658                 }
60659             }
60660             ts.forEach(node.elements, checkSourceElement);
60661             getTypeFromTypeNode(node);
60662         }
60663         function checkUnionOrIntersectionType(node) {
60664             ts.forEach(node.types, checkSourceElement);
60665             getTypeFromTypeNode(node);
60666         }
60667         function checkIndexedAccessIndexType(type, accessNode) {
60668             if (!(type.flags & 8388608)) {
60669                 return type;
60670             }
60671             var objectType = type.objectType;
60672             var indexType = type.indexType;
60673             if (isTypeAssignableTo(indexType, getIndexType(objectType, false))) {
60674                 if (accessNode.kind === 202 && ts.isAssignmentTarget(accessNode) &&
60675                     ts.getObjectFlags(objectType) & 32 && getMappedTypeModifiers(objectType) & 1) {
60676                     error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
60677                 }
60678                 return type;
60679             }
60680             var apparentObjectType = getApparentType(objectType);
60681             if (getIndexInfoOfType(apparentObjectType, 1) && isTypeAssignableToKind(indexType, 296)) {
60682                 return type;
60683             }
60684             if (isGenericObjectType(objectType)) {
60685                 var propertyName_1 = getPropertyNameFromIndex(indexType, accessNode);
60686                 if (propertyName_1) {
60687                     var propertySymbol = forEachType(apparentObjectType, function (t) { return getPropertyOfType(t, propertyName_1); });
60688                     if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24) {
60689                         error(accessNode, ts.Diagnostics.Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter, ts.unescapeLeadingUnderscores(propertyName_1));
60690                         return errorType;
60691                     }
60692                 }
60693             }
60694             error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType));
60695             return errorType;
60696         }
60697         function checkIndexedAccessType(node) {
60698             checkSourceElement(node.objectType);
60699             checkSourceElement(node.indexType);
60700             checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node);
60701         }
60702         function checkMappedType(node) {
60703             checkSourceElement(node.typeParameter);
60704             checkSourceElement(node.nameType);
60705             checkSourceElement(node.type);
60706             if (!node.type) {
60707                 reportImplicitAny(node, anyType);
60708             }
60709             var type = getTypeFromMappedTypeNode(node);
60710             var nameType = getNameTypeFromMappedType(type);
60711             if (nameType) {
60712                 checkTypeAssignableTo(nameType, keyofConstraintType, node.nameType);
60713             }
60714             else {
60715                 var constraintType = getConstraintTypeFromMappedType(type);
60716                 checkTypeAssignableTo(constraintType, keyofConstraintType, ts.getEffectiveConstraintOfTypeParameter(node.typeParameter));
60717             }
60718         }
60719         function checkThisType(node) {
60720             getTypeFromThisTypeNode(node);
60721         }
60722         function checkTypeOperator(node) {
60723             checkGrammarTypeOperatorNode(node);
60724             checkSourceElement(node.type);
60725         }
60726         function checkConditionalType(node) {
60727             ts.forEachChild(node, checkSourceElement);
60728         }
60729         function checkInferType(node) {
60730             if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 184 && n.parent.extendsType === n; })) {
60731                 grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type);
60732             }
60733             checkSourceElement(node.typeParameter);
60734             registerForUnusedIdentifiersCheck(node);
60735         }
60736         function checkTemplateLiteralType(node) {
60737             for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) {
60738                 var span = _a[_i];
60739                 checkSourceElement(span.type);
60740                 var type = getTypeFromTypeNode(span.type);
60741                 checkTypeAssignableTo(type, templateConstraintType, span.type);
60742             }
60743             getTypeFromTypeNode(node);
60744         }
60745         function checkImportType(node) {
60746             checkSourceElement(node.argument);
60747             getTypeFromTypeNode(node);
60748         }
60749         function checkNamedTupleMember(node) {
60750             if (node.dotDotDotToken && node.questionToken) {
60751                 grammarErrorOnNode(node, ts.Diagnostics.A_tuple_member_cannot_be_both_optional_and_rest);
60752             }
60753             if (node.type.kind === 180) {
60754                 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);
60755             }
60756             if (node.type.kind === 181) {
60757                 grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type);
60758             }
60759             checkSourceElement(node.type);
60760             getTypeFromTypeNode(node);
60761         }
60762         function isPrivateWithinAmbient(node) {
60763             return (ts.hasEffectiveModifier(node, 8) || ts.isPrivateIdentifierPropertyDeclaration(node)) && !!(node.flags & 8388608);
60764         }
60765         function getEffectiveDeclarationFlags(n, flagsToCheck) {
60766             var flags = ts.getCombinedModifierFlags(n);
60767             if (n.parent.kind !== 253 &&
60768                 n.parent.kind !== 252 &&
60769                 n.parent.kind !== 221 &&
60770                 n.flags & 8388608) {
60771                 if (!(flags & 2) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) {
60772                     flags |= 1;
60773                 }
60774                 flags |= 2;
60775             }
60776             return flags & flagsToCheck;
60777         }
60778         function checkFunctionOrConstructorSymbol(symbol) {
60779             if (!produceDiagnostics) {
60780                 return;
60781             }
60782             function getCanonicalOverload(overloads, implementation) {
60783                 var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent;
60784                 return implementationSharesContainerWithFirstOverload ? implementation : overloads[0];
60785             }
60786             function checkFlagAgreementBetweenOverloads(overloads, implementation, flagsToCheck, someOverloadFlags, allOverloadFlags) {
60787                 var someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags;
60788                 if (someButNotAllOverloadFlags !== 0) {
60789                     var canonicalFlags_1 = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck);
60790                     ts.forEach(overloads, function (o) {
60791                         var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags_1;
60792                         if (deviation & 1) {
60793                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported);
60794                         }
60795                         else if (deviation & 2) {
60796                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient);
60797                         }
60798                         else if (deviation & (8 | 16)) {
60799                             error(ts.getNameOfDeclaration(o) || o, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected);
60800                         }
60801                         else if (deviation & 128) {
60802                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract);
60803                         }
60804                     });
60805                 }
60806             }
60807             function checkQuestionTokenAgreementBetweenOverloads(overloads, implementation, someHaveQuestionToken, allHaveQuestionToken) {
60808                 if (someHaveQuestionToken !== allHaveQuestionToken) {
60809                     var canonicalHasQuestionToken_1 = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation));
60810                     ts.forEach(overloads, function (o) {
60811                         var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken_1;
60812                         if (deviation) {
60813                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_optional_or_required);
60814                         }
60815                     });
60816                 }
60817             }
60818             var flagsToCheck = 1 | 2 | 8 | 16 | 128;
60819             var someNodeFlags = 0;
60820             var allNodeFlags = flagsToCheck;
60821             var someHaveQuestionToken = false;
60822             var allHaveQuestionToken = true;
60823             var hasOverloads = false;
60824             var bodyDeclaration;
60825             var lastSeenNonAmbientDeclaration;
60826             var previousDeclaration;
60827             var declarations = symbol.declarations;
60828             var isConstructor = (symbol.flags & 16384) !== 0;
60829             function reportImplementationExpectedError(node) {
60830                 if (node.name && ts.nodeIsMissing(node.name)) {
60831                     return;
60832                 }
60833                 var seen = false;
60834                 var subsequentNode = ts.forEachChild(node.parent, function (c) {
60835                     if (seen) {
60836                         return c;
60837                     }
60838                     else {
60839                         seen = c === node;
60840                     }
60841                 });
60842                 if (subsequentNode && subsequentNode.pos === node.end) {
60843                     if (subsequentNode.kind === node.kind) {
60844                         var errorNode_1 = subsequentNode.name || subsequentNode;
60845                         var subsequentName = subsequentNode.name;
60846                         if (node.name && subsequentName && (ts.isPrivateIdentifier(node.name) && ts.isPrivateIdentifier(subsequentName) && node.name.escapedText === subsequentName.escapedText ||
60847                             ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) ||
60848                             ts.isPropertyNameLiteral(node.name) && ts.isPropertyNameLiteral(subsequentName) &&
60849                                 ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) {
60850                             var reportError = (node.kind === 165 || node.kind === 164) &&
60851                                 ts.hasSyntacticModifier(node, 32) !== ts.hasSyntacticModifier(subsequentNode, 32);
60852                             if (reportError) {
60853                                 var diagnostic = ts.hasSyntacticModifier(node, 32) ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static;
60854                                 error(errorNode_1, diagnostic);
60855                             }
60856                             return;
60857                         }
60858                         if (ts.nodeIsPresent(subsequentNode.body)) {
60859                             error(errorNode_1, ts.Diagnostics.Function_implementation_name_must_be_0, ts.declarationNameToString(node.name));
60860                             return;
60861                         }
60862                     }
60863                 }
60864                 var errorNode = node.name || node;
60865                 if (isConstructor) {
60866                     error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing);
60867                 }
60868                 else {
60869                     if (ts.hasSyntacticModifier(node, 128)) {
60870                         error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive);
60871                     }
60872                     else {
60873                         error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration);
60874                     }
60875                 }
60876             }
60877             var duplicateFunctionDeclaration = false;
60878             var multipleConstructorImplementation = false;
60879             var hasNonAmbientClass = false;
60880             var functionDeclarations = [];
60881             for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
60882                 var current = declarations_4[_i];
60883                 var node = current;
60884                 var inAmbientContext = node.flags & 8388608;
60885                 var inAmbientContextOrInterface = node.parent && (node.parent.kind === 253 || node.parent.kind === 177) || inAmbientContext;
60886                 if (inAmbientContextOrInterface) {
60887                     previousDeclaration = undefined;
60888                 }
60889                 if ((node.kind === 252 || node.kind === 221) && !inAmbientContext) {
60890                     hasNonAmbientClass = true;
60891                 }
60892                 if (node.kind === 251 || node.kind === 165 || node.kind === 164 || node.kind === 166) {
60893                     functionDeclarations.push(node);
60894                     var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck);
60895                     someNodeFlags |= currentNodeFlags;
60896                     allNodeFlags &= currentNodeFlags;
60897                     someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node);
60898                     allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node);
60899                     var bodyIsPresent = ts.nodeIsPresent(node.body);
60900                     if (bodyIsPresent && bodyDeclaration) {
60901                         if (isConstructor) {
60902                             multipleConstructorImplementation = true;
60903                         }
60904                         else {
60905                             duplicateFunctionDeclaration = true;
60906                         }
60907                     }
60908                     else if ((previousDeclaration === null || previousDeclaration === void 0 ? void 0 : previousDeclaration.parent) === node.parent && previousDeclaration.end !== node.pos) {
60909                         reportImplementationExpectedError(previousDeclaration);
60910                     }
60911                     if (bodyIsPresent) {
60912                         if (!bodyDeclaration) {
60913                             bodyDeclaration = node;
60914                         }
60915                     }
60916                     else {
60917                         hasOverloads = true;
60918                     }
60919                     previousDeclaration = node;
60920                     if (!inAmbientContextOrInterface) {
60921                         lastSeenNonAmbientDeclaration = node;
60922                     }
60923                 }
60924             }
60925             if (multipleConstructorImplementation) {
60926                 ts.forEach(functionDeclarations, function (declaration) {
60927                     error(declaration, ts.Diagnostics.Multiple_constructor_implementations_are_not_allowed);
60928                 });
60929             }
60930             if (duplicateFunctionDeclaration) {
60931                 ts.forEach(functionDeclarations, function (declaration) {
60932                     error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_function_implementation);
60933                 });
60934             }
60935             if (hasNonAmbientClass && !isConstructor && symbol.flags & 16) {
60936                 ts.forEach(declarations, function (declaration) {
60937                     addDuplicateDeclarationError(declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), declarations);
60938                 });
60939             }
60940             if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body &&
60941                 !ts.hasSyntacticModifier(lastSeenNonAmbientDeclaration, 128) && !lastSeenNonAmbientDeclaration.questionToken) {
60942                 reportImplementationExpectedError(lastSeenNonAmbientDeclaration);
60943             }
60944             if (hasOverloads) {
60945                 checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags);
60946                 checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken);
60947                 if (bodyDeclaration) {
60948                     var signatures = getSignaturesOfSymbol(symbol);
60949                     var bodySignature = getSignatureFromDeclaration(bodyDeclaration);
60950                     for (var _a = 0, signatures_10 = signatures; _a < signatures_10.length; _a++) {
60951                         var signature = signatures_10[_a];
60952                         if (!isImplementationCompatibleWithOverload(bodySignature, signature)) {
60953                             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));
60954                             break;
60955                         }
60956                     }
60957                 }
60958             }
60959         }
60960         function checkExportsOnMergedDeclarations(node) {
60961             if (!produceDiagnostics) {
60962                 return;
60963             }
60964             var symbol = node.localSymbol;
60965             if (!symbol) {
60966                 symbol = getSymbolOfNode(node);
60967                 if (!symbol.exportSymbol) {
60968                     return;
60969                 }
60970             }
60971             if (ts.getDeclarationOfKind(symbol, node.kind) !== node) {
60972                 return;
60973             }
60974             var exportedDeclarationSpaces = 0;
60975             var nonExportedDeclarationSpaces = 0;
60976             var defaultExportedDeclarationSpaces = 0;
60977             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
60978                 var d = _a[_i];
60979                 var declarationSpaces = getDeclarationSpaces(d);
60980                 var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 | 512);
60981                 if (effectiveDeclarationFlags & 1) {
60982                     if (effectiveDeclarationFlags & 512) {
60983                         defaultExportedDeclarationSpaces |= declarationSpaces;
60984                     }
60985                     else {
60986                         exportedDeclarationSpaces |= declarationSpaces;
60987                     }
60988                 }
60989                 else {
60990                     nonExportedDeclarationSpaces |= declarationSpaces;
60991                 }
60992             }
60993             var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces;
60994             var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces;
60995             var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces;
60996             if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) {
60997                 for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) {
60998                     var d = _c[_b];
60999                     var declarationSpaces = getDeclarationSpaces(d);
61000                     var name = ts.getNameOfDeclaration(d);
61001                     if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) {
61002                         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));
61003                     }
61004                     else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) {
61005                         error(name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(name));
61006                     }
61007                 }
61008             }
61009             function getDeclarationSpaces(decl) {
61010                 var d = decl;
61011                 switch (d.kind) {
61012                     case 253:
61013                     case 254:
61014                     case 331:
61015                     case 324:
61016                     case 325:
61017                         return 2;
61018                     case 256:
61019                         return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0
61020                             ? 4 | 1
61021                             : 4;
61022                     case 252:
61023                     case 255:
61024                     case 291:
61025                         return 2 | 1;
61026                     case 297:
61027                         return 2 | 1 | 4;
61028                     case 266:
61029                         if (!ts.isEntityNameExpression(d.expression)) {
61030                             return 1;
61031                         }
61032                         d = d.expression;
61033                     case 260:
61034                     case 263:
61035                     case 262:
61036                         var result_12 = 0;
61037                         var target = resolveAlias(getSymbolOfNode(d));
61038                         ts.forEach(target.declarations, function (d) { result_12 |= getDeclarationSpaces(d); });
61039                         return result_12;
61040                     case 249:
61041                     case 198:
61042                     case 251:
61043                     case 265:
61044                     case 78:
61045                         return 1;
61046                     default:
61047                         return ts.Debug.failBadSyntaxKind(d);
61048                 }
61049             }
61050         }
61051         function getAwaitedTypeOfPromise(type, errorNode, diagnosticMessage, arg0) {
61052             var promisedType = getPromisedTypeOfPromise(type, errorNode);
61053             return promisedType && getAwaitedType(promisedType, errorNode, diagnosticMessage, arg0);
61054         }
61055         function getPromisedTypeOfPromise(type, errorNode) {
61056             if (isTypeAny(type)) {
61057                 return undefined;
61058             }
61059             var typeAsPromise = type;
61060             if (typeAsPromise.promisedTypeOfPromise) {
61061                 return typeAsPromise.promisedTypeOfPromise;
61062             }
61063             if (isReferenceToType(type, getGlobalPromiseType(false))) {
61064                 return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0];
61065             }
61066             var thenFunction = getTypeOfPropertyOfType(type, "then");
61067             if (isTypeAny(thenFunction)) {
61068                 return undefined;
61069             }
61070             var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0) : ts.emptyArray;
61071             if (thenSignatures.length === 0) {
61072                 if (errorNode) {
61073                     error(errorNode, ts.Diagnostics.A_promise_must_have_a_then_method);
61074                 }
61075                 return undefined;
61076             }
61077             var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152);
61078             if (isTypeAny(onfulfilledParameterType)) {
61079                 return undefined;
61080             }
61081             var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0);
61082             if (onfulfilledParameterSignatures.length === 0) {
61083                 if (errorNode) {
61084                     error(errorNode, ts.Diagnostics.The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback);
61085                 }
61086                 return undefined;
61087             }
61088             return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2);
61089         }
61090         function checkAwaitedType(type, errorNode, diagnosticMessage, arg0) {
61091             var awaitedType = getAwaitedType(type, errorNode, diagnosticMessage, arg0);
61092             return awaitedType || errorType;
61093         }
61094         function isThenableType(type) {
61095             var thenFunction = getTypeOfPropertyOfType(type, "then");
61096             return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152), 0).length > 0;
61097         }
61098         function getAwaitedType(type, errorNode, diagnosticMessage, arg0) {
61099             if (isTypeAny(type)) {
61100                 return type;
61101             }
61102             var typeAsAwaitable = type;
61103             if (typeAsAwaitable.awaitedTypeOfType) {
61104                 return typeAsAwaitable.awaitedTypeOfType;
61105             }
61106             return typeAsAwaitable.awaitedTypeOfType =
61107                 mapType(type, errorNode ? function (constituentType) { return getAwaitedTypeWorker(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeWorker);
61108         }
61109         function getAwaitedTypeWorker(type, errorNode, diagnosticMessage, arg0) {
61110             var typeAsAwaitable = type;
61111             if (typeAsAwaitable.awaitedTypeOfType) {
61112                 return typeAsAwaitable.awaitedTypeOfType;
61113             }
61114             var promisedType = getPromisedTypeOfPromise(type);
61115             if (promisedType) {
61116                 if (type.id === promisedType.id || awaitedTypeStack.lastIndexOf(promisedType.id) >= 0) {
61117                     if (errorNode) {
61118                         error(errorNode, ts.Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method);
61119                     }
61120                     return undefined;
61121                 }
61122                 awaitedTypeStack.push(type.id);
61123                 var awaitedType = getAwaitedType(promisedType, errorNode, diagnosticMessage, arg0);
61124                 awaitedTypeStack.pop();
61125                 if (!awaitedType) {
61126                     return undefined;
61127                 }
61128                 return typeAsAwaitable.awaitedTypeOfType = awaitedType;
61129             }
61130             if (isThenableType(type)) {
61131                 if (errorNode) {
61132                     if (!diagnosticMessage)
61133                         return ts.Debug.fail();
61134                     error(errorNode, diagnosticMessage, arg0);
61135                 }
61136                 return undefined;
61137             }
61138             return typeAsAwaitable.awaitedTypeOfType = type;
61139         }
61140         function checkAsyncFunctionReturnType(node, returnTypeNode) {
61141             var returnType = getTypeFromTypeNode(returnTypeNode);
61142             if (languageVersion >= 2) {
61143                 if (returnType === errorType) {
61144                     return;
61145                 }
61146                 var globalPromiseType = getGlobalPromiseType(true);
61147                 if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) {
61148                     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));
61149                     return;
61150                 }
61151             }
61152             else {
61153                 markTypeNodeAsReferenced(returnTypeNode);
61154                 if (returnType === errorType) {
61155                     return;
61156                 }
61157                 var promiseConstructorName = ts.getEntityNameFromTypeNode(returnTypeNode);
61158                 if (promiseConstructorName === undefined) {
61159                     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));
61160                     return;
61161                 }
61162                 var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551, true);
61163                 var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType;
61164                 if (promiseConstructorType === errorType) {
61165                     if (promiseConstructorName.kind === 78 && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(false)) {
61166                         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);
61167                     }
61168                     else {
61169                         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));
61170                     }
61171                     return;
61172                 }
61173                 var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(true);
61174                 if (globalPromiseConstructorLikeType === emptyObjectType) {
61175                     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));
61176                     return;
61177                 }
61178                 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)) {
61179                     return;
61180                 }
61181                 var rootName = promiseConstructorName && ts.getFirstIdentifier(promiseConstructorName);
61182                 var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551);
61183                 if (collidingSymbol) {
61184                     error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName));
61185                     return;
61186                 }
61187             }
61188             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);
61189         }
61190         function checkDecorator(node) {
61191             var signature = getResolvedSignature(node);
61192             checkDeprecatedSignature(signature, node);
61193             var returnType = getReturnTypeOfSignature(signature);
61194             if (returnType.flags & 1) {
61195                 return;
61196             }
61197             var expectedReturnType;
61198             var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
61199             var errorInfo;
61200             switch (node.parent.kind) {
61201                 case 252:
61202                     var classSymbol = getSymbolOfNode(node.parent);
61203                     var classConstructorType = getTypeOfSymbol(classSymbol);
61204                     expectedReturnType = getUnionType([classConstructorType, voidType]);
61205                     break;
61206                 case 160:
61207                     expectedReturnType = voidType;
61208                     errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any);
61209                     break;
61210                 case 163:
61211                     expectedReturnType = voidType;
61212                     errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any);
61213                     break;
61214                 case 165:
61215                 case 167:
61216                 case 168:
61217                     var methodType = getTypeOfNode(node.parent);
61218                     var descriptorType = createTypedPropertyDescriptorType(methodType);
61219                     expectedReturnType = getUnionType([descriptorType, voidType]);
61220                     break;
61221                 default:
61222                     return ts.Debug.fail();
61223             }
61224             checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, function () { return errorInfo; });
61225         }
61226         function markTypeNodeAsReferenced(node) {
61227             markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node));
61228         }
61229         function markEntityNameOrEntityExpressionAsReference(typeName) {
61230             if (!typeName)
61231                 return;
61232             var rootName = ts.getFirstIdentifier(typeName);
61233             var meaning = (typeName.kind === 78 ? 788968 : 1920) | 2097152;
61234             var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, undefined, undefined, true);
61235             if (rootSymbol
61236                 && rootSymbol.flags & 2097152
61237                 && symbolIsValue(rootSymbol)
61238                 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))
61239                 && !getTypeOnlyAliasDeclaration(rootSymbol)) {
61240                 markAliasSymbolAsReferenced(rootSymbol);
61241             }
61242         }
61243         function markDecoratorMedataDataTypeNodeAsReferenced(node) {
61244             var entityName = getEntityNameForDecoratorMetadata(node);
61245             if (entityName && ts.isEntityName(entityName)) {
61246                 markEntityNameOrEntityExpressionAsReference(entityName);
61247             }
61248         }
61249         function getEntityNameForDecoratorMetadata(node) {
61250             if (node) {
61251                 switch (node.kind) {
61252                     case 183:
61253                     case 182:
61254                         return getEntityNameForDecoratorMetadataFromTypeList(node.types);
61255                     case 184:
61256                         return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]);
61257                     case 186:
61258                     case 192:
61259                         return getEntityNameForDecoratorMetadata(node.type);
61260                     case 173:
61261                         return node.typeName;
61262                 }
61263             }
61264         }
61265         function getEntityNameForDecoratorMetadataFromTypeList(types) {
61266             var commonEntityName;
61267             for (var _i = 0, types_21 = types; _i < types_21.length; _i++) {
61268                 var typeNode = types_21[_i];
61269                 while (typeNode.kind === 186 || typeNode.kind === 192) {
61270                     typeNode = typeNode.type;
61271                 }
61272                 if (typeNode.kind === 141) {
61273                     continue;
61274                 }
61275                 if (!strictNullChecks && (typeNode.kind === 191 && typeNode.literal.kind === 103 || typeNode.kind === 150)) {
61276                     continue;
61277                 }
61278                 var individualEntityName = getEntityNameForDecoratorMetadata(typeNode);
61279                 if (!individualEntityName) {
61280                     return undefined;
61281                 }
61282                 if (commonEntityName) {
61283                     if (!ts.isIdentifier(commonEntityName) ||
61284                         !ts.isIdentifier(individualEntityName) ||
61285                         commonEntityName.escapedText !== individualEntityName.escapedText) {
61286                         return undefined;
61287                     }
61288                 }
61289                 else {
61290                     commonEntityName = individualEntityName;
61291                 }
61292             }
61293             return commonEntityName;
61294         }
61295         function getParameterTypeNodeForDecoratorCheck(node) {
61296             var typeNode = ts.getEffectiveTypeAnnotationNode(node);
61297             return ts.isRestParameter(node) ? ts.getRestParameterElementType(typeNode) : typeNode;
61298         }
61299         function checkDecorators(node) {
61300             if (!node.decorators) {
61301                 return;
61302             }
61303             if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) {
61304                 return;
61305             }
61306             if (!compilerOptions.experimentalDecorators) {
61307                 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);
61308             }
61309             var firstDecorator = node.decorators[0];
61310             checkExternalEmitHelpers(firstDecorator, 8);
61311             if (node.kind === 160) {
61312                 checkExternalEmitHelpers(firstDecorator, 32);
61313             }
61314             if (compilerOptions.emitDecoratorMetadata) {
61315                 checkExternalEmitHelpers(firstDecorator, 16);
61316                 switch (node.kind) {
61317                     case 252:
61318                         var constructor = ts.getFirstConstructorWithBody(node);
61319                         if (constructor) {
61320                             for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) {
61321                                 var parameter = _a[_i];
61322                                 markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
61323                             }
61324                         }
61325                         break;
61326                     case 167:
61327                     case 168:
61328                         var otherKind = node.kind === 167 ? 168 : 167;
61329                         var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind);
61330                         markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor));
61331                         break;
61332                     case 165:
61333                         for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) {
61334                             var parameter = _c[_b];
61335                             markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
61336                         }
61337                         markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node));
61338                         break;
61339                     case 163:
61340                         markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node));
61341                         break;
61342                     case 160:
61343                         markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node));
61344                         var containingSignature = node.parent;
61345                         for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) {
61346                             var parameter = _e[_d];
61347                             markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
61348                         }
61349                         break;
61350                 }
61351             }
61352             ts.forEach(node.decorators, checkDecorator);
61353         }
61354         function checkFunctionDeclaration(node) {
61355             if (produceDiagnostics) {
61356                 checkFunctionOrMethodDeclaration(node);
61357                 checkGrammarForGenerator(node);
61358                 checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
61359                 checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
61360             }
61361         }
61362         function checkJSDocTypeAliasTag(node) {
61363             if (!node.typeExpression) {
61364                 error(node.name, ts.Diagnostics.JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags);
61365             }
61366             if (node.name) {
61367                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0);
61368             }
61369             checkSourceElement(node.typeExpression);
61370         }
61371         function checkJSDocTemplateTag(node) {
61372             checkSourceElement(node.constraint);
61373             for (var _i = 0, _a = node.typeParameters; _i < _a.length; _i++) {
61374                 var tp = _a[_i];
61375                 checkSourceElement(tp);
61376             }
61377         }
61378         function checkJSDocTypeTag(node) {
61379             checkSourceElement(node.typeExpression);
61380         }
61381         function checkJSDocParameterTag(node) {
61382             checkSourceElement(node.typeExpression);
61383             if (!ts.getParameterSymbolFromJSDoc(node)) {
61384                 var decl = ts.getHostSignatureFromJSDoc(node);
61385                 if (decl) {
61386                     var i = ts.getJSDocTags(decl).filter(ts.isJSDocParameterTag).indexOf(node);
61387                     if (i > -1 && i < decl.parameters.length && ts.isBindingPattern(decl.parameters[i].name)) {
61388                         return;
61389                     }
61390                     if (!containsArgumentsReference(decl)) {
61391                         if (ts.isQualifiedName(node.name)) {
61392                             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));
61393                         }
61394                         else {
61395                             error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name));
61396                         }
61397                     }
61398                     else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node &&
61399                         node.typeExpression && node.typeExpression.type &&
61400                         !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) {
61401                         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));
61402                     }
61403                 }
61404             }
61405         }
61406         function checkJSDocPropertyTag(node) {
61407             checkSourceElement(node.typeExpression);
61408         }
61409         function checkJSDocFunctionType(node) {
61410             if (produceDiagnostics && !node.type && !ts.isJSDocConstructSignature(node)) {
61411                 reportImplicitAny(node, anyType);
61412             }
61413             checkSignatureDeclaration(node);
61414         }
61415         function checkJSDocImplementsTag(node) {
61416             var classLike = ts.getEffectiveJSDocHost(node);
61417             if (!classLike || !ts.isClassDeclaration(classLike) && !ts.isClassExpression(classLike)) {
61418                 error(classLike, ts.Diagnostics.JSDoc_0_is_not_attached_to_a_class, ts.idText(node.tagName));
61419             }
61420         }
61421         function checkJSDocAugmentsTag(node) {
61422             var classLike = ts.getEffectiveJSDocHost(node);
61423             if (!classLike || !ts.isClassDeclaration(classLike) && !ts.isClassExpression(classLike)) {
61424                 error(classLike, ts.Diagnostics.JSDoc_0_is_not_attached_to_a_class, ts.idText(node.tagName));
61425                 return;
61426             }
61427             var augmentsTags = ts.getJSDocTags(classLike).filter(ts.isJSDocAugmentsTag);
61428             ts.Debug.assert(augmentsTags.length > 0);
61429             if (augmentsTags.length > 1) {
61430                 error(augmentsTags[1], ts.Diagnostics.Class_declarations_cannot_have_more_than_one_augments_or_extends_tag);
61431             }
61432             var name = getIdentifierFromEntityNameExpression(node.class.expression);
61433             var extend = ts.getClassExtendsHeritageElement(classLike);
61434             if (extend) {
61435                 var className = getIdentifierFromEntityNameExpression(extend.expression);
61436                 if (className && name.escapedText !== className.escapedText) {
61437                     error(name, ts.Diagnostics.JSDoc_0_1_does_not_match_the_extends_2_clause, ts.idText(node.tagName), ts.idText(name), ts.idText(className));
61438                 }
61439             }
61440         }
61441         function getIdentifierFromEntityNameExpression(node) {
61442             switch (node.kind) {
61443                 case 78:
61444                     return node;
61445                 case 201:
61446                     return node.name;
61447                 default:
61448                     return undefined;
61449             }
61450         }
61451         function checkFunctionOrMethodDeclaration(node) {
61452             checkDecorators(node);
61453             checkSignatureDeclaration(node);
61454             var functionFlags = ts.getFunctionFlags(node);
61455             if (node.name && node.name.kind === 158) {
61456                 checkComputedPropertyName(node.name);
61457             }
61458             if (!hasNonBindableDynamicName(node)) {
61459                 var symbol = getSymbolOfNode(node);
61460                 var localSymbol = node.localSymbol || symbol;
61461                 var firstDeclaration = ts.find(localSymbol.declarations, function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072); });
61462                 if (node === firstDeclaration) {
61463                     checkFunctionOrConstructorSymbol(localSymbol);
61464                 }
61465                 if (symbol.parent) {
61466                     checkFunctionOrConstructorSymbol(symbol);
61467                 }
61468             }
61469             var body = node.kind === 164 ? undefined : node.body;
61470             checkSourceElement(body);
61471             checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node));
61472             if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) {
61473                 if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) {
61474                     reportImplicitAny(node, anyType);
61475                 }
61476                 if (functionFlags & 1 && ts.nodeIsPresent(body)) {
61477                     getReturnTypeOfSignature(getSignatureFromDeclaration(node));
61478                 }
61479             }
61480             if (ts.isInJSFile(node)) {
61481                 var typeTag = ts.getJSDocTypeTag(node);
61482                 if (typeTag && typeTag.typeExpression && !getContextualCallSignature(getTypeFromTypeNode(typeTag.typeExpression), node)) {
61483                     error(typeTag, ts.Diagnostics.The_type_of_a_function_declaration_must_match_the_function_s_signature);
61484                 }
61485             }
61486         }
61487         function registerForUnusedIdentifiersCheck(node) {
61488             if (produceDiagnostics) {
61489                 var sourceFile = ts.getSourceFileOfNode(node);
61490                 var potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path);
61491                 if (!potentiallyUnusedIdentifiers) {
61492                     potentiallyUnusedIdentifiers = [];
61493                     allPotentiallyUnusedIdentifiers.set(sourceFile.path, potentiallyUnusedIdentifiers);
61494                 }
61495                 potentiallyUnusedIdentifiers.push(node);
61496             }
61497         }
61498         function checkUnusedIdentifiers(potentiallyUnusedIdentifiers, addDiagnostic) {
61499             for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) {
61500                 var node = potentiallyUnusedIdentifiers_1[_i];
61501                 switch (node.kind) {
61502                     case 252:
61503                     case 221:
61504                         checkUnusedClassMembers(node, addDiagnostic);
61505                         checkUnusedTypeParameters(node, addDiagnostic);
61506                         break;
61507                     case 297:
61508                     case 256:
61509                     case 230:
61510                     case 258:
61511                     case 237:
61512                     case 238:
61513                     case 239:
61514                         checkUnusedLocalsAndParameters(node, addDiagnostic);
61515                         break;
61516                     case 166:
61517                     case 208:
61518                     case 251:
61519                     case 209:
61520                     case 165:
61521                     case 167:
61522                     case 168:
61523                         if (node.body) {
61524                             checkUnusedLocalsAndParameters(node, addDiagnostic);
61525                         }
61526                         checkUnusedTypeParameters(node, addDiagnostic);
61527                         break;
61528                     case 164:
61529                     case 169:
61530                     case 170:
61531                     case 174:
61532                     case 175:
61533                     case 254:
61534                     case 253:
61535                         checkUnusedTypeParameters(node, addDiagnostic);
61536                         break;
61537                     case 185:
61538                         checkUnusedInferTypeParameter(node, addDiagnostic);
61539                         break;
61540                     default:
61541                         ts.Debug.assertNever(node, "Node should not have been registered for unused identifiers check");
61542                 }
61543             }
61544         }
61545         function errorUnusedLocal(declaration, name, addDiagnostic) {
61546             var node = ts.getNameOfDeclaration(declaration) || declaration;
61547             var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
61548             addDiagnostic(declaration, 0, ts.createDiagnosticForNode(node, message, name));
61549         }
61550         function isIdentifierThatStartsWithUnderscore(node) {
61551             return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95;
61552         }
61553         function checkUnusedClassMembers(node, addDiagnostic) {
61554             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
61555                 var member = _a[_i];
61556                 switch (member.kind) {
61557                     case 165:
61558                     case 163:
61559                     case 167:
61560                     case 168:
61561                         if (member.kind === 168 && member.symbol.flags & 32768) {
61562                             break;
61563                         }
61564                         var symbol = getSymbolOfNode(member);
61565                         if (!symbol.isReferenced
61566                             && (ts.hasEffectiveModifier(member, 8) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name))
61567                             && !(member.flags & 8388608)) {
61568                             addDiagnostic(member, 0, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol)));
61569                         }
61570                         break;
61571                     case 166:
61572                         for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) {
61573                             var parameter = _c[_b];
61574                             if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8)) {
61575                                 addDiagnostic(parameter, 0, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol)));
61576                             }
61577                         }
61578                         break;
61579                     case 171:
61580                     case 229:
61581                         break;
61582                     default:
61583                         ts.Debug.fail();
61584                 }
61585             }
61586         }
61587         function checkUnusedInferTypeParameter(node, addDiagnostic) {
61588             var typeParameter = node.typeParameter;
61589             if (isTypeParameterUnused(typeParameter)) {
61590                 addDiagnostic(node, 1, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name)));
61591             }
61592         }
61593         function checkUnusedTypeParameters(node, addDiagnostic) {
61594             if (ts.last(getSymbolOfNode(node).declarations) !== node)
61595                 return;
61596             var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
61597             var seenParentsWithEveryUnused = new ts.Set();
61598             for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) {
61599                 var typeParameter = typeParameters_3[_i];
61600                 if (!isTypeParameterUnused(typeParameter))
61601                     continue;
61602                 var name = ts.idText(typeParameter.name);
61603                 var parent = typeParameter.parent;
61604                 if (parent.kind !== 185 && parent.typeParameters.every(isTypeParameterUnused)) {
61605                     if (ts.tryAddToSet(seenParentsWithEveryUnused, parent)) {
61606                         var range = ts.isJSDocTemplateTag(parent)
61607                             ? ts.rangeOfNode(parent)
61608                             : ts.rangeOfTypeParameters(parent.typeParameters);
61609                         var only = parent.typeParameters.length === 1;
61610                         var message = only ? ts.Diagnostics._0_is_declared_but_its_value_is_never_read : ts.Diagnostics.All_type_parameters_are_unused;
61611                         var arg0 = only ? name : undefined;
61612                         addDiagnostic(typeParameter, 1, ts.createFileDiagnostic(ts.getSourceFileOfNode(parent), range.pos, range.end - range.pos, message, arg0));
61613                     }
61614                 }
61615                 else {
61616                     addDiagnostic(typeParameter, 1, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name));
61617                 }
61618             }
61619         }
61620         function isTypeParameterUnused(typeParameter) {
61621             return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144) && !isIdentifierThatStartsWithUnderscore(typeParameter.name);
61622         }
61623         function addToGroup(map, key, value, getKey) {
61624             var keyString = String(getKey(key));
61625             var group = map.get(keyString);
61626             if (group) {
61627                 group[1].push(value);
61628             }
61629             else {
61630                 map.set(keyString, [key, [value]]);
61631             }
61632         }
61633         function tryGetRootParameterDeclaration(node) {
61634             return ts.tryCast(ts.getRootDeclaration(node), ts.isParameter);
61635         }
61636         function isValidUnusedLocalDeclaration(declaration) {
61637             if (ts.isBindingElement(declaration) && isIdentifierThatStartsWithUnderscore(declaration.name)) {
61638                 return !!ts.findAncestor(declaration.parent, function (ancestor) {
61639                     return ts.isArrayBindingPattern(ancestor) || ts.isVariableDeclaration(ancestor) || ts.isVariableDeclarationList(ancestor) ? false :
61640                         ts.isForOfStatement(ancestor) ? true : "quit";
61641                 });
61642             }
61643             return ts.isAmbientModule(declaration) ||
61644                 (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderscore(declaration.name);
61645         }
61646         function checkUnusedLocalsAndParameters(nodeWithLocals, addDiagnostic) {
61647             var unusedImports = new ts.Map();
61648             var unusedDestructures = new ts.Map();
61649             var unusedVariables = new ts.Map();
61650             nodeWithLocals.locals.forEach(function (local) {
61651                 if (local.flags & 262144 ? !(local.flags & 3 && !(local.isReferenced & 3)) : local.isReferenced || local.exportSymbol) {
61652                     return;
61653                 }
61654                 for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) {
61655                     var declaration = _a[_i];
61656                     if (isValidUnusedLocalDeclaration(declaration)) {
61657                         continue;
61658                     }
61659                     if (isImportedDeclaration(declaration)) {
61660                         addToGroup(unusedImports, importClauseFromImported(declaration), declaration, getNodeId);
61661                     }
61662                     else if (ts.isBindingElement(declaration) && ts.isObjectBindingPattern(declaration.parent)) {
61663                         var lastElement = ts.last(declaration.parent.elements);
61664                         if (declaration === lastElement || !ts.last(declaration.parent.elements).dotDotDotToken) {
61665                             addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId);
61666                         }
61667                     }
61668                     else if (ts.isVariableDeclaration(declaration)) {
61669                         addToGroup(unusedVariables, declaration.parent, declaration, getNodeId);
61670                     }
61671                     else {
61672                         var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration);
61673                         var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration);
61674                         if (parameter && name) {
61675                             if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) {
61676                                 addDiagnostic(parameter, 1, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local)));
61677                             }
61678                         }
61679                         else {
61680                             errorUnusedLocal(declaration, ts.symbolName(local), addDiagnostic);
61681                         }
61682                     }
61683                 }
61684             });
61685             unusedImports.forEach(function (_a) {
61686                 var importClause = _a[0], unuseds = _a[1];
61687                 var importDecl = importClause.parent;
61688                 var nDeclarations = (importClause.name ? 1 : 0) +
61689                     (importClause.namedBindings ?
61690                         (importClause.namedBindings.kind === 263 ? 1 : importClause.namedBindings.elements.length)
61691                         : 0);
61692                 if (nDeclarations === unuseds.length) {
61693                     addDiagnostic(importDecl, 0, unuseds.length === 1
61694                         ? ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name))
61695                         : ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused));
61696                 }
61697                 else {
61698                     for (var _i = 0, unuseds_1 = unuseds; _i < unuseds_1.length; _i++) {
61699                         var unused = unuseds_1[_i];
61700                         errorUnusedLocal(unused, ts.idText(unused.name), addDiagnostic);
61701                     }
61702                 }
61703             });
61704             unusedDestructures.forEach(function (_a) {
61705                 var bindingPattern = _a[0], bindingElements = _a[1];
61706                 var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 : 0;
61707                 if (bindingPattern.elements.length === bindingElements.length) {
61708                     if (bindingElements.length === 1 && bindingPattern.parent.kind === 249 && bindingPattern.parent.parent.kind === 250) {
61709                         addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId);
61710                     }
61711                     else {
61712                         addDiagnostic(bindingPattern, kind, bindingElements.length === 1
61713                             ? ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(bindingElements).name))
61714                             : ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics.All_destructured_elements_are_unused));
61715                     }
61716                 }
61717                 else {
61718                     for (var _i = 0, bindingElements_1 = bindingElements; _i < bindingElements_1.length; _i++) {
61719                         var e = bindingElements_1[_i];
61720                         addDiagnostic(e, kind, ts.createDiagnosticForNode(e, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(e.name)));
61721                     }
61722                 }
61723             });
61724             unusedVariables.forEach(function (_a) {
61725                 var declarationList = _a[0], declarations = _a[1];
61726                 if (declarationList.declarations.length === declarations.length) {
61727                     addDiagnostic(declarationList, 0, declarations.length === 1
61728                         ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name))
61729                         : ts.createDiagnosticForNode(declarationList.parent.kind === 232 ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused));
61730                 }
61731                 else {
61732                     for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
61733                         var decl = declarations_5[_i];
61734                         addDiagnostic(decl, 0, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name)));
61735                     }
61736                 }
61737             });
61738         }
61739         function bindingNameText(name) {
61740             switch (name.kind) {
61741                 case 78:
61742                     return ts.idText(name);
61743                 case 197:
61744                 case 196:
61745                     return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name);
61746                 default:
61747                     return ts.Debug.assertNever(name);
61748             }
61749         }
61750         function isImportedDeclaration(node) {
61751             return node.kind === 262 || node.kind === 265 || node.kind === 263;
61752         }
61753         function importClauseFromImported(decl) {
61754             return decl.kind === 262 ? decl : decl.kind === 263 ? decl.parent : decl.parent.parent;
61755         }
61756         function checkBlock(node) {
61757             if (node.kind === 230) {
61758                 checkGrammarStatementInAmbientContext(node);
61759             }
61760             if (ts.isFunctionOrModuleBlock(node)) {
61761                 var saveFlowAnalysisDisabled = flowAnalysisDisabled;
61762                 ts.forEach(node.statements, checkSourceElement);
61763                 flowAnalysisDisabled = saveFlowAnalysisDisabled;
61764             }
61765             else {
61766                 ts.forEach(node.statements, checkSourceElement);
61767             }
61768             if (node.locals) {
61769                 registerForUnusedIdentifiersCheck(node);
61770             }
61771         }
61772         function checkCollisionWithArgumentsInGeneratedCode(node) {
61773             if (languageVersion >= 2 || !ts.hasRestParameter(node) || node.flags & 8388608 || ts.nodeIsMissing(node.body)) {
61774                 return;
61775             }
61776             ts.forEach(node.parameters, function (p) {
61777                 if (p.name && !ts.isBindingPattern(p.name) && p.name.escapedText === argumentsSymbol.escapedName) {
61778                     errorSkippedOn("noEmit", p, ts.Diagnostics.Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters);
61779                 }
61780             });
61781         }
61782         function needCollisionCheckForIdentifier(node, identifier, name) {
61783             if (!(identifier && identifier.escapedText === name)) {
61784                 return false;
61785             }
61786             if (node.kind === 163 ||
61787                 node.kind === 162 ||
61788                 node.kind === 165 ||
61789                 node.kind === 164 ||
61790                 node.kind === 167 ||
61791                 node.kind === 168) {
61792                 return false;
61793             }
61794             if (node.flags & 8388608) {
61795                 return false;
61796             }
61797             var root = ts.getRootDeclaration(node);
61798             if (root.kind === 160 && ts.nodeIsMissing(root.parent.body)) {
61799                 return false;
61800             }
61801             return true;
61802         }
61803         function checkIfThisIsCapturedInEnclosingScope(node) {
61804             ts.findAncestor(node, function (current) {
61805                 if (getNodeCheckFlags(current) & 4) {
61806                     var isDeclaration_1 = node.kind !== 78;
61807                     if (isDeclaration_1) {
61808                         error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference);
61809                     }
61810                     else {
61811                         error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference);
61812                     }
61813                     return true;
61814                 }
61815                 return false;
61816             });
61817         }
61818         function checkIfNewTargetIsCapturedInEnclosingScope(node) {
61819             ts.findAncestor(node, function (current) {
61820                 if (getNodeCheckFlags(current) & 8) {
61821                     var isDeclaration_2 = node.kind !== 78;
61822                     if (isDeclaration_2) {
61823                         error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference);
61824                     }
61825                     else {
61826                         error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference);
61827                     }
61828                     return true;
61829                 }
61830                 return false;
61831             });
61832         }
61833         function checkWeakMapCollision(node) {
61834             var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node);
61835             if (getNodeCheckFlags(enclosingBlockScope) & 67108864) {
61836                 errorSkippedOn("noEmit", node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, "WeakMap");
61837             }
61838         }
61839         function checkCollisionWithRequireExportsInGeneratedCode(node, name) {
61840             if (moduleKind >= ts.ModuleKind.ES2015) {
61841                 return;
61842             }
61843             if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) {
61844                 return;
61845             }
61846             if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1) {
61847                 return;
61848             }
61849             var parent = getDeclarationContainer(node);
61850             if (parent.kind === 297 && ts.isExternalOrCommonJsModule(parent)) {
61851                 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));
61852             }
61853         }
61854         function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) {
61855             if (languageVersion >= 4 || !needCollisionCheckForIdentifier(node, name, "Promise")) {
61856                 return;
61857             }
61858             if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1) {
61859                 return;
61860             }
61861             var parent = getDeclarationContainer(node);
61862             if (parent.kind === 297 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048) {
61863                 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));
61864             }
61865         }
61866         function checkVarDeclaredNamesNotShadowed(node) {
61867             if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) {
61868                 return;
61869             }
61870             if (node.kind === 249 && !node.initializer) {
61871                 return;
61872             }
61873             var symbol = getSymbolOfNode(node);
61874             if (symbol.flags & 1) {
61875                 if (!ts.isIdentifier(node.name))
61876                     return ts.Debug.fail();
61877                 var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3, undefined, undefined, false);
61878                 if (localDeclarationSymbol &&
61879                     localDeclarationSymbol !== symbol &&
61880                     localDeclarationSymbol.flags & 2) {
61881                     if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) {
61882                         var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 250);
61883                         var container = varDeclList.parent.kind === 232 && varDeclList.parent.parent
61884                             ? varDeclList.parent.parent
61885                             : undefined;
61886                         var namesShareScope = container &&
61887                             (container.kind === 230 && ts.isFunctionLike(container.parent) ||
61888                                 container.kind === 257 ||
61889                                 container.kind === 256 ||
61890                                 container.kind === 297);
61891                         if (!namesShareScope) {
61892                             var name = symbolToString(localDeclarationSymbol);
61893                             error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name);
61894                         }
61895                     }
61896                 }
61897             }
61898         }
61899         function convertAutoToAny(type) {
61900             return type === autoType ? anyType : type === autoArrayType ? anyArrayType : type;
61901         }
61902         function checkVariableLikeDeclaration(node) {
61903             var _a;
61904             checkDecorators(node);
61905             if (!ts.isBindingElement(node)) {
61906                 checkSourceElement(node.type);
61907             }
61908             if (!node.name) {
61909                 return;
61910             }
61911             if (node.name.kind === 158) {
61912                 checkComputedPropertyName(node.name);
61913                 if (node.initializer) {
61914                     checkExpressionCached(node.initializer);
61915                 }
61916             }
61917             if (node.kind === 198) {
61918                 if (node.parent.kind === 196 && languageVersion < 99) {
61919                     checkExternalEmitHelpers(node, 4);
61920                 }
61921                 if (node.propertyName && node.propertyName.kind === 158) {
61922                     checkComputedPropertyName(node.propertyName);
61923                 }
61924                 var parent = node.parent.parent;
61925                 var parentType = getTypeForBindingElementParent(parent);
61926                 var name = node.propertyName || node.name;
61927                 if (parentType && !ts.isBindingPattern(name)) {
61928                     var exprType = getLiteralTypeFromPropertyName(name);
61929                     if (isTypeUsableAsPropertyName(exprType)) {
61930                         var nameText = getPropertyNameFromType(exprType);
61931                         var property = getPropertyOfType(parentType, nameText);
61932                         if (property) {
61933                             markPropertyAsReferenced(property, undefined, false);
61934                             checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 105, parentType, property);
61935                         }
61936                     }
61937                 }
61938             }
61939             if (ts.isBindingPattern(node.name)) {
61940                 if (node.name.kind === 197 && languageVersion < 2 && compilerOptions.downlevelIteration) {
61941                     checkExternalEmitHelpers(node, 512);
61942                 }
61943                 ts.forEach(node.name.elements, checkSourceElement);
61944             }
61945             if (node.initializer && ts.isParameterDeclaration(node) && ts.nodeIsMissing(ts.getContainingFunction(node).body)) {
61946                 error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation);
61947                 return;
61948             }
61949             if (ts.isBindingPattern(node.name)) {
61950                 var needCheckInitializer = node.initializer && node.parent.parent.kind !== 238;
61951                 var needCheckWidenedType = node.name.elements.length === 0;
61952                 if (needCheckInitializer || needCheckWidenedType) {
61953                     var widenedType = getWidenedTypeForVariableLikeDeclaration(node);
61954                     if (needCheckInitializer) {
61955                         var initializerType = checkExpressionCached(node.initializer);
61956                         if (strictNullChecks && needCheckWidenedType) {
61957                             checkNonNullNonVoidType(initializerType, node);
61958                         }
61959                         else {
61960                             checkTypeAssignableToAndOptionallyElaborate(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, node.initializer);
61961                         }
61962                     }
61963                     if (needCheckWidenedType) {
61964                         if (ts.isArrayBindingPattern(node.name)) {
61965                             checkIteratedTypeOrElementType(65, widenedType, undefinedType, node);
61966                         }
61967                         else if (strictNullChecks) {
61968                             checkNonNullNonVoidType(widenedType, node);
61969                         }
61970                     }
61971                 }
61972                 return;
61973             }
61974             var symbol = getSymbolOfNode(node);
61975             if (symbol.flags & 2097152 && ts.isRequireVariableDeclaration(node, true)) {
61976                 checkAliasSymbol(node);
61977                 return;
61978             }
61979             var type = convertAutoToAny(getTypeOfSymbol(symbol));
61980             if (node === symbol.valueDeclaration) {
61981                 var initializer = ts.getEffectiveInitializer(node);
61982                 if (initializer) {
61983                     var isJSObjectLiteralInitializer = ts.isInJSFile(node) &&
61984                         ts.isObjectLiteralExpression(initializer) &&
61985                         (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) &&
61986                         !!((_a = symbol.exports) === null || _a === void 0 ? void 0 : _a.size);
61987                     if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 238) {
61988                         checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, undefined);
61989                     }
61990                 }
61991                 if (symbol.declarations.length > 1) {
61992                     if (ts.some(symbol.declarations, function (d) { return d !== node && ts.isVariableLike(d) && !areDeclarationFlagsIdentical(d, node); })) {
61993                         error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name));
61994                     }
61995                 }
61996             }
61997             else {
61998                 var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node));
61999                 if (type !== errorType && declarationType !== errorType &&
62000                     !isTypeIdenticalTo(type, declarationType) &&
62001                     !(symbol.flags & 67108864)) {
62002                     errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType);
62003                 }
62004                 if (node.initializer) {
62005                     checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, undefined);
62006                 }
62007                 if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) {
62008                     error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name));
62009                 }
62010             }
62011             if (node.kind !== 163 && node.kind !== 162) {
62012                 checkExportsOnMergedDeclarations(node);
62013                 if (node.kind === 249 || node.kind === 198) {
62014                     checkVarDeclaredNamesNotShadowed(node);
62015                 }
62016                 checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
62017                 checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
62018                 if (languageVersion < 99 && needCollisionCheckForIdentifier(node, node.name, "WeakMap")) {
62019                     potentialWeakMapCollisions.push(node);
62020                 }
62021             }
62022         }
62023         function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) {
62024             var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration);
62025             var message = nextDeclaration.kind === 163 || nextDeclaration.kind === 162
62026                 ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2
62027                 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2;
62028             var declName = ts.declarationNameToString(nextDeclarationName);
62029             var err = error(nextDeclarationName, message, declName, typeToString(firstType), typeToString(nextType));
62030             if (firstDeclaration) {
62031                 ts.addRelatedInfo(err, ts.createDiagnosticForNode(firstDeclaration, ts.Diagnostics._0_was_also_declared_here, declName));
62032             }
62033         }
62034         function areDeclarationFlagsIdentical(left, right) {
62035             if ((left.kind === 160 && right.kind === 249) ||
62036                 (left.kind === 249 && right.kind === 160)) {
62037                 return true;
62038             }
62039             if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) {
62040                 return false;
62041             }
62042             var interestingFlags = 8 |
62043                 16 |
62044                 256 |
62045                 128 |
62046                 64 |
62047                 32;
62048             return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags);
62049         }
62050         function checkVariableDeclaration(node) {
62051             ts.tracing.push("check", "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end });
62052             checkGrammarVariableDeclaration(node);
62053             checkVariableLikeDeclaration(node);
62054             ts.tracing.pop();
62055         }
62056         function checkBindingElement(node) {
62057             checkGrammarBindingElement(node);
62058             return checkVariableLikeDeclaration(node);
62059         }
62060         function checkVariableStatement(node) {
62061             if (!checkGrammarDecoratorsAndModifiers(node) && !checkGrammarVariableDeclarationList(node.declarationList))
62062                 checkGrammarForDisallowedLetOrConstStatement(node);
62063             ts.forEach(node.declarationList.declarations, checkSourceElement);
62064         }
62065         function checkExpressionStatement(node) {
62066             checkGrammarStatementInAmbientContext(node);
62067             checkExpression(node.expression);
62068         }
62069         function checkIfStatement(node) {
62070             checkGrammarStatementInAmbientContext(node);
62071             var type = checkTruthinessExpression(node.expression);
62072             checkTestingKnownTruthyCallableType(node.expression, node.thenStatement, type);
62073             checkSourceElement(node.thenStatement);
62074             if (node.thenStatement.kind === 231) {
62075                 error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement);
62076             }
62077             checkSourceElement(node.elseStatement);
62078         }
62079         function checkTestingKnownTruthyCallableType(condExpr, body, type) {
62080             if (!strictNullChecks) {
62081                 return;
62082             }
62083             var testedNode = ts.isIdentifier(condExpr)
62084                 ? condExpr
62085                 : ts.isPropertyAccessExpression(condExpr)
62086                     ? condExpr.name
62087                     : undefined;
62088             if (!testedNode) {
62089                 return;
62090             }
62091             var possiblyFalsy = getFalsyFlags(type);
62092             if (possiblyFalsy) {
62093                 return;
62094             }
62095             var callSignatures = getSignaturesOfType(type, 0);
62096             if (callSignatures.length === 0) {
62097                 return;
62098             }
62099             var testedFunctionSymbol = getSymbolAtLocation(testedNode);
62100             if (!testedFunctionSymbol) {
62101                 return;
62102             }
62103             var functionIsUsedInBody = ts.forEachChild(body, function check(childNode) {
62104                 if (ts.isIdentifier(childNode)) {
62105                     var childSymbol = getSymbolAtLocation(childNode);
62106                     if (childSymbol && childSymbol === testedFunctionSymbol) {
62107                         if (ts.isIdentifier(condExpr)) {
62108                             return true;
62109                         }
62110                         var testedExpression = testedNode.parent;
62111                         var childExpression = childNode.parent;
62112                         while (testedExpression && childExpression) {
62113                             if (ts.isIdentifier(testedExpression) && ts.isIdentifier(childExpression) ||
62114                                 testedExpression.kind === 107 && childExpression.kind === 107) {
62115                                 return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression);
62116                             }
62117                             if (ts.isPropertyAccessExpression(testedExpression) && ts.isPropertyAccessExpression(childExpression)) {
62118                                 if (getSymbolAtLocation(testedExpression.name) !== getSymbolAtLocation(childExpression.name)) {
62119                                     return false;
62120                                 }
62121                                 childExpression = childExpression.expression;
62122                                 testedExpression = testedExpression.expression;
62123                             }
62124                             else {
62125                                 return false;
62126                             }
62127                         }
62128                     }
62129                 }
62130                 return ts.forEachChild(childNode, check);
62131             });
62132             if (!functionIsUsedInBody) {
62133                 error(condExpr, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead);
62134             }
62135         }
62136         function checkDoStatement(node) {
62137             checkGrammarStatementInAmbientContext(node);
62138             checkSourceElement(node.statement);
62139             checkTruthinessExpression(node.expression);
62140         }
62141         function checkWhileStatement(node) {
62142             checkGrammarStatementInAmbientContext(node);
62143             checkTruthinessExpression(node.expression);
62144             checkSourceElement(node.statement);
62145         }
62146         function checkTruthinessOfType(type, node) {
62147             if (type.flags & 16384) {
62148                 error(node, ts.Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness);
62149             }
62150             return type;
62151         }
62152         function checkTruthinessExpression(node, checkMode) {
62153             return checkTruthinessOfType(checkExpression(node, checkMode), node);
62154         }
62155         function checkForStatement(node) {
62156             if (!checkGrammarStatementInAmbientContext(node)) {
62157                 if (node.initializer && node.initializer.kind === 250) {
62158                     checkGrammarVariableDeclarationList(node.initializer);
62159                 }
62160             }
62161             if (node.initializer) {
62162                 if (node.initializer.kind === 250) {
62163                     ts.forEach(node.initializer.declarations, checkVariableDeclaration);
62164                 }
62165                 else {
62166                     checkExpression(node.initializer);
62167                 }
62168             }
62169             if (node.condition)
62170                 checkTruthinessExpression(node.condition);
62171             if (node.incrementor)
62172                 checkExpression(node.incrementor);
62173             checkSourceElement(node.statement);
62174             if (node.locals) {
62175                 registerForUnusedIdentifiersCheck(node);
62176             }
62177         }
62178         function checkForOfStatement(node) {
62179             checkGrammarForInOrForOfStatement(node);
62180             if (node.awaitModifier) {
62181                 var functionFlags = ts.getFunctionFlags(ts.getContainingFunction(node));
62182                 if ((functionFlags & (4 | 2)) === 2 && languageVersion < 99) {
62183                     checkExternalEmitHelpers(node, 32768);
62184                 }
62185             }
62186             else if (compilerOptions.downlevelIteration && languageVersion < 2) {
62187                 checkExternalEmitHelpers(node, 256);
62188             }
62189             if (node.initializer.kind === 250) {
62190                 checkForInOrForOfVariableDeclaration(node);
62191             }
62192             else {
62193                 var varExpr = node.initializer;
62194                 var iteratedType = checkRightHandSideOfForOf(node);
62195                 if (varExpr.kind === 199 || varExpr.kind === 200) {
62196                     checkDestructuringAssignment(varExpr, iteratedType || errorType);
62197                 }
62198                 else {
62199                     var leftType = checkExpression(varExpr);
62200                     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);
62201                     if (iteratedType) {
62202                         checkTypeAssignableToAndOptionallyElaborate(iteratedType, leftType, varExpr, node.expression);
62203                     }
62204                 }
62205             }
62206             checkSourceElement(node.statement);
62207             if (node.locals) {
62208                 registerForUnusedIdentifiersCheck(node);
62209             }
62210         }
62211         function checkForInStatement(node) {
62212             checkGrammarForInOrForOfStatement(node);
62213             var rightType = getNonNullableTypeIfNeeded(checkExpression(node.expression));
62214             if (node.initializer.kind === 250) {
62215                 var variable = node.initializer.declarations[0];
62216                 if (variable && ts.isBindingPattern(variable.name)) {
62217                     error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern);
62218                 }
62219                 checkForInOrForOfVariableDeclaration(node);
62220             }
62221             else {
62222                 var varExpr = node.initializer;
62223                 var leftType = checkExpression(varExpr);
62224                 if (varExpr.kind === 199 || varExpr.kind === 200) {
62225                     error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern);
62226                 }
62227                 else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) {
62228                     error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any);
62229                 }
62230                 else {
62231                     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);
62232                 }
62233             }
62234             if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 | 58982400)) {
62235                 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));
62236             }
62237             checkSourceElement(node.statement);
62238             if (node.locals) {
62239                 registerForUnusedIdentifiersCheck(node);
62240             }
62241         }
62242         function checkForInOrForOfVariableDeclaration(iterationStatement) {
62243             var variableDeclarationList = iterationStatement.initializer;
62244             if (variableDeclarationList.declarations.length >= 1) {
62245                 var decl = variableDeclarationList.declarations[0];
62246                 checkVariableDeclaration(decl);
62247             }
62248         }
62249         function checkRightHandSideOfForOf(statement) {
62250             var use = statement.awaitModifier ? 15 : 13;
62251             return checkIteratedTypeOrElementType(use, checkNonNullExpression(statement.expression), undefinedType, statement.expression);
62252         }
62253         function checkIteratedTypeOrElementType(use, inputType, sentType, errorNode) {
62254             if (isTypeAny(inputType)) {
62255                 return inputType;
62256             }
62257             return getIteratedTypeOrElementType(use, inputType, sentType, errorNode, true) || anyType;
62258         }
62259         function getIteratedTypeOrElementType(use, inputType, sentType, errorNode, checkAssignability) {
62260             var allowAsyncIterables = (use & 2) !== 0;
62261             if (inputType === neverType) {
62262                 reportTypeNotIterableError(errorNode, inputType, allowAsyncIterables);
62263                 return undefined;
62264             }
62265             var uplevelIteration = languageVersion >= 2;
62266             var downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration;
62267             var possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & 128);
62268             if (uplevelIteration || downlevelIteration || allowAsyncIterables) {
62269                 var iterationTypes = getIterationTypesOfIterable(inputType, use, uplevelIteration ? errorNode : undefined);
62270                 if (checkAssignability) {
62271                     if (iterationTypes) {
62272                         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 :
62273                             use & 32 ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 :
62274                                 use & 64 ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 :
62275                                     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 :
62276                                         undefined;
62277                         if (diagnostic) {
62278                             checkTypeAssignableTo(sentType, iterationTypes.nextType, errorNode, diagnostic);
62279                         }
62280                     }
62281                 }
62282                 if (iterationTypes || uplevelIteration) {
62283                     return possibleOutOfBounds ? includeUndefinedInIndexSignature(iterationTypes && iterationTypes.yieldType) : (iterationTypes && iterationTypes.yieldType);
62284                 }
62285             }
62286             var arrayType = inputType;
62287             var reportedError = false;
62288             var hasStringConstituent = false;
62289             if (use & 4) {
62290                 if (arrayType.flags & 1048576) {
62291                     var arrayTypes = inputType.types;
62292                     var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 402653316); });
62293                     if (filteredTypes !== arrayTypes) {
62294                         arrayType = getUnionType(filteredTypes, 2);
62295                     }
62296                 }
62297                 else if (arrayType.flags & 402653316) {
62298                     arrayType = neverType;
62299                 }
62300                 hasStringConstituent = arrayType !== inputType;
62301                 if (hasStringConstituent) {
62302                     if (languageVersion < 1) {
62303                         if (errorNode) {
62304                             error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher);
62305                             reportedError = true;
62306                         }
62307                     }
62308                     if (arrayType.flags & 131072) {
62309                         return possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType;
62310                     }
62311                 }
62312             }
62313             if (!isArrayLikeType(arrayType)) {
62314                 if (errorNode && !reportedError) {
62315                     var yieldType = getIterationTypeOfIterable(use, 0, inputType, undefined);
62316                     var _a = !(use & 4) || hasStringConstituent
62317                         ? downlevelIteration
62318                             ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true]
62319                             : yieldType
62320                                 ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]
62321                                 : [ts.Diagnostics.Type_0_is_not_an_array_type, true]
62322                         : downlevelIteration
62323                             ? [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]
62324                             : yieldType
62325                                 ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]
62326                                 : [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type, true], defaultDiagnostic = _a[0], maybeMissingAwait = _a[1];
62327                     errorAndMaybeSuggestAwait(errorNode, maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType), defaultDiagnostic, typeToString(arrayType));
62328                 }
62329                 return hasStringConstituent ? possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType : undefined;
62330             }
62331             var arrayElementType = getIndexTypeOfType(arrayType, 1);
62332             if (hasStringConstituent && arrayElementType) {
62333                 if (arrayElementType.flags & 402653316 && !compilerOptions.noUncheckedIndexedAccess) {
62334                     return stringType;
62335                 }
62336                 return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2);
62337             }
62338             return (use & 128) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType;
62339         }
62340         function getIterationTypeOfIterable(use, typeKind, inputType, errorNode) {
62341             if (isTypeAny(inputType)) {
62342                 return undefined;
62343             }
62344             var iterationTypes = getIterationTypesOfIterable(inputType, use, errorNode);
62345             return iterationTypes && iterationTypes[getIterationTypesKeyFromIterationTypeKind(typeKind)];
62346         }
62347         function createIterationTypes(yieldType, returnType, nextType) {
62348             if (yieldType === void 0) { yieldType = neverType; }
62349             if (returnType === void 0) { returnType = neverType; }
62350             if (nextType === void 0) { nextType = unknownType; }
62351             if (yieldType.flags & 67359327 &&
62352                 returnType.flags & (1 | 131072 | 2 | 16384 | 32768) &&
62353                 nextType.flags & (1 | 131072 | 2 | 16384 | 32768)) {
62354                 var id = getTypeListId([yieldType, returnType, nextType]);
62355                 var iterationTypes = iterationTypesCache.get(id);
62356                 if (!iterationTypes) {
62357                     iterationTypes = { yieldType: yieldType, returnType: returnType, nextType: nextType };
62358                     iterationTypesCache.set(id, iterationTypes);
62359                 }
62360                 return iterationTypes;
62361             }
62362             return { yieldType: yieldType, returnType: returnType, nextType: nextType };
62363         }
62364         function combineIterationTypes(array) {
62365             var yieldTypes;
62366             var returnTypes;
62367             var nextTypes;
62368             for (var _i = 0, array_10 = array; _i < array_10.length; _i++) {
62369                 var iterationTypes = array_10[_i];
62370                 if (iterationTypes === undefined || iterationTypes === noIterationTypes) {
62371                     continue;
62372                 }
62373                 if (iterationTypes === anyIterationTypes) {
62374                     return anyIterationTypes;
62375                 }
62376                 yieldTypes = ts.append(yieldTypes, iterationTypes.yieldType);
62377                 returnTypes = ts.append(returnTypes, iterationTypes.returnType);
62378                 nextTypes = ts.append(nextTypes, iterationTypes.nextType);
62379             }
62380             if (yieldTypes || returnTypes || nextTypes) {
62381                 return createIterationTypes(yieldTypes && getUnionType(yieldTypes), returnTypes && getUnionType(returnTypes), nextTypes && getIntersectionType(nextTypes));
62382             }
62383             return noIterationTypes;
62384         }
62385         function getCachedIterationTypes(type, cacheKey) {
62386             return type[cacheKey];
62387         }
62388         function setCachedIterationTypes(type, cacheKey, cachedTypes) {
62389             return type[cacheKey] = cachedTypes;
62390         }
62391         function getIterationTypesOfIterable(type, use, errorNode) {
62392             if (isTypeAny(type)) {
62393                 return anyIterationTypes;
62394             }
62395             if (!(type.flags & 1048576)) {
62396                 var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode);
62397                 if (iterationTypes_1 === noIterationTypes) {
62398                     if (errorNode) {
62399                         reportTypeNotIterableError(errorNode, type, !!(use & 2));
62400                     }
62401                     return undefined;
62402                 }
62403                 return iterationTypes_1;
62404             }
62405             var cacheKey = use & 2 ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable";
62406             var cachedTypes = getCachedIterationTypes(type, cacheKey);
62407             if (cachedTypes)
62408                 return cachedTypes === noIterationTypes ? undefined : cachedTypes;
62409             var allIterationTypes;
62410             for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
62411                 var constituent = _a[_i];
62412                 var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode);
62413                 if (iterationTypes_2 === noIterationTypes) {
62414                     if (errorNode) {
62415                         reportTypeNotIterableError(errorNode, type, !!(use & 2));
62416                     }
62417                     setCachedIterationTypes(type, cacheKey, noIterationTypes);
62418                     return undefined;
62419                 }
62420                 else {
62421                     allIterationTypes = ts.append(allIterationTypes, iterationTypes_2);
62422                 }
62423             }
62424             var iterationTypes = allIterationTypes ? combineIterationTypes(allIterationTypes) : noIterationTypes;
62425             setCachedIterationTypes(type, cacheKey, iterationTypes);
62426             return iterationTypes === noIterationTypes ? undefined : iterationTypes;
62427         }
62428         function getAsyncFromSyncIterationTypes(iterationTypes, errorNode) {
62429             if (iterationTypes === noIterationTypes)
62430                 return noIterationTypes;
62431             if (iterationTypes === anyIterationTypes)
62432                 return anyIterationTypes;
62433             var yieldType = iterationTypes.yieldType, returnType = iterationTypes.returnType, nextType = iterationTypes.nextType;
62434             return createIterationTypes(getAwaitedType(yieldType, errorNode) || anyType, getAwaitedType(returnType, errorNode) || anyType, nextType);
62435         }
62436         function getIterationTypesOfIterableWorker(type, use, errorNode) {
62437             if (isTypeAny(type)) {
62438                 return anyIterationTypes;
62439             }
62440             if (use & 2) {
62441                 var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) ||
62442                     getIterationTypesOfIterableFast(type, asyncIterationTypesResolver);
62443                 if (iterationTypes) {
62444                     return iterationTypes;
62445                 }
62446             }
62447             if (use & 1) {
62448                 var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) ||
62449                     getIterationTypesOfIterableFast(type, syncIterationTypesResolver);
62450                 if (iterationTypes) {
62451                     if (use & 2) {
62452                         if (iterationTypes !== noIterationTypes) {
62453                             return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode));
62454                         }
62455                     }
62456                     else {
62457                         return iterationTypes;
62458                     }
62459                 }
62460             }
62461             if (use & 2) {
62462                 var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode);
62463                 if (iterationTypes !== noIterationTypes) {
62464                     return iterationTypes;
62465                 }
62466             }
62467             if (use & 1) {
62468                 var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode);
62469                 if (iterationTypes !== noIterationTypes) {
62470                     if (use & 2) {
62471                         return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes
62472                             ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode)
62473                             : noIterationTypes);
62474                     }
62475                     else {
62476                         return iterationTypes;
62477                     }
62478                 }
62479             }
62480             return noIterationTypes;
62481         }
62482         function getIterationTypesOfIterableCached(type, resolver) {
62483             return getCachedIterationTypes(type, resolver.iterableCacheKey);
62484         }
62485         function getIterationTypesOfGlobalIterableType(globalType, resolver) {
62486             var globalIterationTypes = getIterationTypesOfIterableCached(globalType, resolver) ||
62487                 getIterationTypesOfIterableSlow(globalType, resolver, undefined);
62488             return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes;
62489         }
62490         function getIterationTypesOfIterableFast(type, resolver) {
62491             var globalType;
62492             if (isReferenceToType(type, globalType = resolver.getGlobalIterableType(false)) ||
62493                 isReferenceToType(type, globalType = resolver.getGlobalIterableIteratorType(false))) {
62494                 var yieldType = getTypeArguments(type)[0];
62495                 var _a = getIterationTypesOfGlobalIterableType(globalType, resolver), returnType = _a.returnType, nextType = _a.nextType;
62496                 return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(yieldType, returnType, nextType));
62497             }
62498             if (isReferenceToType(type, resolver.getGlobalGeneratorType(false))) {
62499                 var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2];
62500                 return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(yieldType, returnType, nextType));
62501             }
62502         }
62503         function getIterationTypesOfIterableSlow(type, resolver, errorNode) {
62504             var _a;
62505             var method = getPropertyOfType(type, ts.getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName));
62506             var methodType = method && !(method.flags & 16777216) ? getTypeOfSymbol(method) : undefined;
62507             if (isTypeAny(methodType)) {
62508                 return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
62509             }
62510             var signatures = methodType ? getSignaturesOfType(methodType, 0) : undefined;
62511             if (!ts.some(signatures)) {
62512                 return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
62513             }
62514             var iteratorType = getIntersectionType(ts.map(signatures, getReturnTypeOfSignature));
62515             var iterationTypes = (_a = getIterationTypesOfIterator(iteratorType, resolver, errorNode)) !== null && _a !== void 0 ? _a : noIterationTypes;
62516             return setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
62517         }
62518         function reportTypeNotIterableError(errorNode, type, allowAsyncIterables) {
62519             var message = allowAsyncIterables
62520                 ? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
62521                 : ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
62522             errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
62523         }
62524         function getIterationTypesOfIterator(type, resolver, errorNode) {
62525             if (isTypeAny(type)) {
62526                 return anyIterationTypes;
62527             }
62528             var iterationTypes = getIterationTypesOfIteratorCached(type, resolver) ||
62529                 getIterationTypesOfIteratorFast(type, resolver) ||
62530                 getIterationTypesOfIteratorSlow(type, resolver, errorNode);
62531             return iterationTypes === noIterationTypes ? undefined : iterationTypes;
62532         }
62533         function getIterationTypesOfIteratorCached(type, resolver) {
62534             return getCachedIterationTypes(type, resolver.iteratorCacheKey);
62535         }
62536         function getIterationTypesOfIteratorFast(type, resolver) {
62537             var globalType = resolver.getGlobalIterableIteratorType(false);
62538             if (isReferenceToType(type, globalType)) {
62539                 var yieldType = getTypeArguments(type)[0];
62540                 var globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) ||
62541                     getIterationTypesOfIteratorSlow(globalType, resolver, undefined);
62542                 var _a = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes, returnType = _a.returnType, nextType = _a.nextType;
62543                 return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType));
62544             }
62545             if (isReferenceToType(type, resolver.getGlobalIteratorType(false)) ||
62546                 isReferenceToType(type, resolver.getGlobalGeneratorType(false))) {
62547                 var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2];
62548                 return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType));
62549             }
62550         }
62551         function isIteratorResult(type, kind) {
62552             var doneType = getTypeOfPropertyOfType(type, "done") || falseType;
62553             return isTypeAssignableTo(kind === 0 ? falseType : trueType, doneType);
62554         }
62555         function isYieldIteratorResult(type) {
62556             return isIteratorResult(type, 0);
62557         }
62558         function isReturnIteratorResult(type) {
62559             return isIteratorResult(type, 1);
62560         }
62561         function getIterationTypesOfIteratorResult(type) {
62562             if (isTypeAny(type)) {
62563                 return anyIterationTypes;
62564             }
62565             var cachedTypes = getCachedIterationTypes(type, "iterationTypesOfIteratorResult");
62566             if (cachedTypes) {
62567                 return cachedTypes;
62568             }
62569             if (isReferenceToType(type, getGlobalIteratorYieldResultType(false))) {
62570                 var yieldType_1 = getTypeArguments(type)[0];
62571                 return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", createIterationTypes(yieldType_1, undefined, undefined));
62572             }
62573             if (isReferenceToType(type, getGlobalIteratorReturnResultType(false))) {
62574                 var returnType_1 = getTypeArguments(type)[0];
62575                 return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", createIterationTypes(undefined, returnType_1, undefined));
62576             }
62577             var yieldIteratorResult = filterType(type, isYieldIteratorResult);
62578             var yieldType = yieldIteratorResult !== neverType ? getTypeOfPropertyOfType(yieldIteratorResult, "value") : undefined;
62579             var returnIteratorResult = filterType(type, isReturnIteratorResult);
62580             var returnType = returnIteratorResult !== neverType ? getTypeOfPropertyOfType(returnIteratorResult, "value") : undefined;
62581             if (!yieldType && !returnType) {
62582                 return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", noIterationTypes);
62583             }
62584             return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", createIterationTypes(yieldType, returnType || voidType, undefined));
62585         }
62586         function getIterationTypesOfMethod(type, resolver, methodName, errorNode) {
62587             var _a, _b, _c, _d;
62588             var method = getPropertyOfType(type, methodName);
62589             if (!method && methodName !== "next") {
62590                 return undefined;
62591             }
62592             var methodType = method && !(methodName === "next" && (method.flags & 16777216))
62593                 ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152)
62594                 : undefined;
62595             if (isTypeAny(methodType)) {
62596                 return methodName === "next" ? anyIterationTypes : anyIterationTypesExceptNext;
62597             }
62598             var methodSignatures = methodType ? getSignaturesOfType(methodType, 0) : ts.emptyArray;
62599             if (methodSignatures.length === 0) {
62600                 if (errorNode) {
62601                     var diagnostic = methodName === "next"
62602                         ? resolver.mustHaveANextMethodDiagnostic
62603                         : resolver.mustBeAMethodDiagnostic;
62604                     error(errorNode, diagnostic, methodName);
62605                 }
62606                 return methodName === "next" ? anyIterationTypes : undefined;
62607             }
62608             if ((methodType === null || methodType === void 0 ? void 0 : methodType.symbol) && methodSignatures.length === 1) {
62609                 var globalGeneratorType = resolver.getGlobalGeneratorType(false);
62610                 var globalIteratorType = resolver.getGlobalIteratorType(false);
62611                 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;
62612                 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;
62613                 if (isGeneratorMethod || isIteratorMethod) {
62614                     var globalType = isGeneratorMethod ? globalGeneratorType : globalIteratorType;
62615                     var mapper = methodType.mapper;
62616                     return createIterationTypes(getMappedType(globalType.typeParameters[0], mapper), getMappedType(globalType.typeParameters[1], mapper), methodName === "next" ? getMappedType(globalType.typeParameters[2], mapper) : undefined);
62617                 }
62618             }
62619             var methodParameterTypes;
62620             var methodReturnTypes;
62621             for (var _i = 0, methodSignatures_1 = methodSignatures; _i < methodSignatures_1.length; _i++) {
62622                 var signature = methodSignatures_1[_i];
62623                 if (methodName !== "throw" && ts.some(signature.parameters)) {
62624                     methodParameterTypes = ts.append(methodParameterTypes, getTypeAtPosition(signature, 0));
62625                 }
62626                 methodReturnTypes = ts.append(methodReturnTypes, getReturnTypeOfSignature(signature));
62627             }
62628             var returnTypes;
62629             var nextType;
62630             if (methodName !== "throw") {
62631                 var methodParameterType = methodParameterTypes ? getUnionType(methodParameterTypes) : unknownType;
62632                 if (methodName === "next") {
62633                     nextType = methodParameterType;
62634                 }
62635                 else if (methodName === "return") {
62636                     var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType;
62637                     returnTypes = ts.append(returnTypes, resolvedMethodParameterType);
62638                 }
62639             }
62640             var yieldType;
62641             var methodReturnType = methodReturnTypes ? getIntersectionType(methodReturnTypes) : neverType;
62642             var resolvedMethodReturnType = resolver.resolveIterationType(methodReturnType, errorNode) || anyType;
62643             var iterationTypes = getIterationTypesOfIteratorResult(resolvedMethodReturnType);
62644             if (iterationTypes === noIterationTypes) {
62645                 if (errorNode) {
62646                     error(errorNode, resolver.mustHaveAValueDiagnostic, methodName);
62647                 }
62648                 yieldType = anyType;
62649                 returnTypes = ts.append(returnTypes, anyType);
62650             }
62651             else {
62652                 yieldType = iterationTypes.yieldType;
62653                 returnTypes = ts.append(returnTypes, iterationTypes.returnType);
62654             }
62655             return createIterationTypes(yieldType, getUnionType(returnTypes), nextType);
62656         }
62657         function getIterationTypesOfIteratorSlow(type, resolver, errorNode) {
62658             var iterationTypes = combineIterationTypes([
62659                 getIterationTypesOfMethod(type, resolver, "next", errorNode),
62660                 getIterationTypesOfMethod(type, resolver, "return", errorNode),
62661                 getIterationTypesOfMethod(type, resolver, "throw", errorNode),
62662             ]);
62663             return setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes);
62664         }
62665         function getIterationTypeOfGeneratorFunctionReturnType(kind, returnType, isAsyncGenerator) {
62666             if (isTypeAny(returnType)) {
62667                 return undefined;
62668             }
62669             var iterationTypes = getIterationTypesOfGeneratorFunctionReturnType(returnType, isAsyncGenerator);
62670             return iterationTypes && iterationTypes[getIterationTypesKeyFromIterationTypeKind(kind)];
62671         }
62672         function getIterationTypesOfGeneratorFunctionReturnType(type, isAsyncGenerator) {
62673             if (isTypeAny(type)) {
62674                 return anyIterationTypes;
62675             }
62676             var use = isAsyncGenerator ? 2 : 1;
62677             var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver;
62678             return getIterationTypesOfIterable(type, use, undefined) ||
62679                 getIterationTypesOfIterator(type, resolver, undefined);
62680         }
62681         function checkBreakOrContinueStatement(node) {
62682             if (!checkGrammarStatementInAmbientContext(node))
62683                 checkGrammarBreakOrContinueStatement(node);
62684         }
62685         function unwrapReturnType(returnType, functionFlags) {
62686             var _a, _b;
62687             var isGenerator = !!(functionFlags & 1);
62688             var isAsync = !!(functionFlags & 2);
62689             return isGenerator ? (_a = getIterationTypeOfGeneratorFunctionReturnType(1, returnType, isAsync)) !== null && _a !== void 0 ? _a : errorType :
62690                 isAsync ? (_b = getAwaitedType(returnType)) !== null && _b !== void 0 ? _b : errorType :
62691                     returnType;
62692         }
62693         function isUnwrappedReturnTypeVoidOrAny(func, returnType) {
62694             var unwrappedReturnType = unwrapReturnType(returnType, ts.getFunctionFlags(func));
62695             return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 | 3);
62696         }
62697         function checkReturnStatement(node) {
62698             var _a;
62699             if (checkGrammarStatementInAmbientContext(node)) {
62700                 return;
62701             }
62702             var func = ts.getContainingFunction(node);
62703             if (!func) {
62704                 grammarErrorOnFirstToken(node, ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body);
62705                 return;
62706             }
62707             var signature = getSignatureFromDeclaration(func);
62708             var returnType = getReturnTypeOfSignature(signature);
62709             var functionFlags = ts.getFunctionFlags(func);
62710             if (strictNullChecks || node.expression || returnType.flags & 131072) {
62711                 var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
62712                 if (func.kind === 168) {
62713                     if (node.expression) {
62714                         error(node, ts.Diagnostics.Setters_cannot_return_a_value);
62715                     }
62716                 }
62717                 else if (func.kind === 166) {
62718                     if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) {
62719                         error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
62720                     }
62721                 }
62722                 else if (getReturnTypeFromAnnotation(func)) {
62723                     var unwrappedReturnType = (_a = unwrapReturnType(returnType, functionFlags)) !== null && _a !== void 0 ? _a : returnType;
62724                     var unwrappedExprType = functionFlags & 2
62725                         ? 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)
62726                         : exprType;
62727                     if (unwrappedReturnType) {
62728                         checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, node, node.expression);
62729                     }
62730                 }
62731             }
62732             else if (func.kind !== 166 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) {
62733                 error(node, ts.Diagnostics.Not_all_code_paths_return_a_value);
62734             }
62735         }
62736         function checkWithStatement(node) {
62737             if (!checkGrammarStatementInAmbientContext(node)) {
62738                 if (node.flags & 32768) {
62739                     grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block);
62740                 }
62741             }
62742             checkExpression(node.expression);
62743             var sourceFile = ts.getSourceFileOfNode(node);
62744             if (!hasParseDiagnostics(sourceFile)) {
62745                 var start = ts.getSpanOfTokenAtPosition(sourceFile, node.pos).start;
62746                 var end = node.statement.pos;
62747                 grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any);
62748             }
62749         }
62750         function checkSwitchStatement(node) {
62751             checkGrammarStatementInAmbientContext(node);
62752             var firstDefaultClause;
62753             var hasDuplicateDefaultClause = false;
62754             var expressionType = checkExpression(node.expression);
62755             var expressionIsLiteral = isLiteralType(expressionType);
62756             ts.forEach(node.caseBlock.clauses, function (clause) {
62757                 if (clause.kind === 285 && !hasDuplicateDefaultClause) {
62758                     if (firstDefaultClause === undefined) {
62759                         firstDefaultClause = clause;
62760                     }
62761                     else {
62762                         grammarErrorOnNode(clause, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement);
62763                         hasDuplicateDefaultClause = true;
62764                     }
62765                 }
62766                 if (produceDiagnostics && clause.kind === 284) {
62767                     var caseType = checkExpression(clause.expression);
62768                     var caseIsLiteral = isLiteralType(caseType);
62769                     var comparedExpressionType = expressionType;
62770                     if (!caseIsLiteral || !expressionIsLiteral) {
62771                         caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType;
62772                         comparedExpressionType = getBaseTypeOfLiteralType(expressionType);
62773                     }
62774                     if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) {
62775                         checkTypeComparableTo(caseType, comparedExpressionType, clause.expression, undefined);
62776                     }
62777                 }
62778                 ts.forEach(clause.statements, checkSourceElement);
62779                 if (compilerOptions.noFallthroughCasesInSwitch && clause.fallthroughFlowNode && isReachableFlowNode(clause.fallthroughFlowNode)) {
62780                     error(clause, ts.Diagnostics.Fallthrough_case_in_switch);
62781                 }
62782             });
62783             if (node.caseBlock.locals) {
62784                 registerForUnusedIdentifiersCheck(node.caseBlock);
62785             }
62786         }
62787         function checkLabeledStatement(node) {
62788             if (!checkGrammarStatementInAmbientContext(node)) {
62789                 ts.findAncestor(node.parent, function (current) {
62790                     if (ts.isFunctionLike(current)) {
62791                         return "quit";
62792                     }
62793                     if (current.kind === 245 && current.label.escapedText === node.label.escapedText) {
62794                         grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label));
62795                         return true;
62796                     }
62797                     return false;
62798                 });
62799             }
62800             checkSourceElement(node.statement);
62801         }
62802         function checkThrowStatement(node) {
62803             if (!checkGrammarStatementInAmbientContext(node)) {
62804                 if (ts.isIdentifier(node.expression) && !node.expression.escapedText) {
62805                     grammarErrorAfterFirstToken(node, ts.Diagnostics.Line_break_not_permitted_here);
62806                 }
62807             }
62808             if (node.expression) {
62809                 checkExpression(node.expression);
62810             }
62811         }
62812         function checkTryStatement(node) {
62813             checkGrammarStatementInAmbientContext(node);
62814             checkBlock(node.tryBlock);
62815             var catchClause = node.catchClause;
62816             if (catchClause) {
62817                 if (catchClause.variableDeclaration) {
62818                     var declaration = catchClause.variableDeclaration;
62819                     if (declaration.type) {
62820                         var type = getTypeForVariableLikeDeclaration(declaration, false);
62821                         if (type && !(type.flags & 3)) {
62822                             grammarErrorOnFirstToken(declaration.type, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified);
62823                         }
62824                     }
62825                     else if (declaration.initializer) {
62826                         grammarErrorOnFirstToken(declaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer);
62827                     }
62828                     else {
62829                         var blockLocals_1 = catchClause.block.locals;
62830                         if (blockLocals_1) {
62831                             ts.forEachKey(catchClause.locals, function (caughtName) {
62832                                 var blockLocal = blockLocals_1.get(caughtName);
62833                                 if (blockLocal && (blockLocal.flags & 2) !== 0) {
62834                                     grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName);
62835                                 }
62836                             });
62837                         }
62838                     }
62839                 }
62840                 checkBlock(catchClause.block);
62841             }
62842             if (node.finallyBlock) {
62843                 checkBlock(node.finallyBlock);
62844             }
62845         }
62846         function checkIndexConstraints(type) {
62847             var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1);
62848             var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0);
62849             var stringIndexType = getIndexTypeOfType(type, 0);
62850             var numberIndexType = getIndexTypeOfType(type, 1);
62851             if (stringIndexType || numberIndexType) {
62852                 ts.forEach(getPropertiesOfObjectType(type), function (prop) {
62853                     var propType = getTypeOfSymbol(prop);
62854                     checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0);
62855                     checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1);
62856                 });
62857                 var classDeclaration = type.symbol.valueDeclaration;
62858                 if (ts.getObjectFlags(type) & 1 && ts.isClassLike(classDeclaration)) {
62859                     for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) {
62860                         var member = _a[_i];
62861                         if (!ts.hasSyntacticModifier(member, 32) && hasNonBindableDynamicName(member)) {
62862                             var symbol = getSymbolOfNode(member);
62863                             var propType = getTypeOfSymbol(symbol);
62864                             checkIndexConstraintForProperty(symbol, propType, type, declaredStringIndexer, stringIndexType, 0);
62865                             checkIndexConstraintForProperty(symbol, propType, type, declaredNumberIndexer, numberIndexType, 1);
62866                         }
62867                     }
62868                 }
62869             }
62870             var errorNode;
62871             if (stringIndexType && numberIndexType) {
62872                 errorNode = declaredNumberIndexer || declaredStringIndexer;
62873                 if (!errorNode && (ts.getObjectFlags(type) & 2)) {
62874                     var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0) && getIndexTypeOfType(base, 1); });
62875                     errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0];
62876                 }
62877             }
62878             if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) {
62879                 error(errorNode, ts.Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1, typeToString(numberIndexType), typeToString(stringIndexType));
62880             }
62881             function checkIndexConstraintForProperty(prop, propertyType, containingType, indexDeclaration, indexType, indexKind) {
62882                 if (!indexType || ts.isKnownSymbol(prop)) {
62883                     return;
62884                 }
62885                 var propDeclaration = prop.valueDeclaration;
62886                 var name = propDeclaration && ts.getNameOfDeclaration(propDeclaration);
62887                 if (name && ts.isPrivateIdentifier(name)) {
62888                     return;
62889                 }
62890                 if (indexKind === 1 && !(name ? isNumericName(name) : isNumericLiteralName(prop.escapedName))) {
62891                     return;
62892                 }
62893                 var errorNode;
62894                 if (propDeclaration && name &&
62895                     (propDeclaration.kind === 216 ||
62896                         name.kind === 158 ||
62897                         prop.parent === containingType.symbol)) {
62898                     errorNode = propDeclaration;
62899                 }
62900                 else if (indexDeclaration) {
62901                     errorNode = indexDeclaration;
62902                 }
62903                 else if (ts.getObjectFlags(containingType) & 2) {
62904                     var someBaseClassHasBothPropertyAndIndexer = ts.forEach(getBaseTypes(containingType), function (base) { return getPropertyOfObjectType(base, prop.escapedName) && getIndexTypeOfType(base, indexKind); });
62905                     errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0];
62906                 }
62907                 if (errorNode && !isTypeAssignableTo(propertyType, indexType)) {
62908                     var errorMessage = indexKind === 0
62909                         ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2
62910                         : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2;
62911                     error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType));
62912                 }
62913             }
62914         }
62915         function checkTypeNameIsReserved(name, message) {
62916             switch (name.escapedText) {
62917                 case "any":
62918                 case "unknown":
62919                 case "number":
62920                 case "bigint":
62921                 case "boolean":
62922                 case "string":
62923                 case "symbol":
62924                 case "void":
62925                 case "object":
62926                     error(name, message, name.escapedText);
62927             }
62928         }
62929         function checkClassNameCollisionWithObject(name) {
62930             if (languageVersion === 1 && name.escapedText === "Object"
62931                 && moduleKind < ts.ModuleKind.ES2015) {
62932                 error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]);
62933             }
62934         }
62935         function checkTypeParameters(typeParameterDeclarations) {
62936             if (typeParameterDeclarations) {
62937                 var seenDefault = false;
62938                 for (var i = 0; i < typeParameterDeclarations.length; i++) {
62939                     var node = typeParameterDeclarations[i];
62940                     checkTypeParameter(node);
62941                     if (produceDiagnostics) {
62942                         if (node.default) {
62943                             seenDefault = true;
62944                             checkTypeParametersNotReferenced(node.default, typeParameterDeclarations, i);
62945                         }
62946                         else if (seenDefault) {
62947                             error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters);
62948                         }
62949                         for (var j = 0; j < i; j++) {
62950                             if (typeParameterDeclarations[j].symbol === node.symbol) {
62951                                 error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name));
62952                             }
62953                         }
62954                     }
62955                 }
62956             }
62957         }
62958         function checkTypeParametersNotReferenced(root, typeParameters, index) {
62959             visit(root);
62960             function visit(node) {
62961                 if (node.kind === 173) {
62962                     var type = getTypeFromTypeReference(node);
62963                     if (type.flags & 262144) {
62964                         for (var i = index; i < typeParameters.length; i++) {
62965                             if (type.symbol === getSymbolOfNode(typeParameters[i])) {
62966                                 error(node, ts.Diagnostics.Type_parameter_defaults_can_only_reference_previously_declared_type_parameters);
62967                             }
62968                         }
62969                     }
62970                 }
62971                 ts.forEachChild(node, visit);
62972             }
62973         }
62974         function checkTypeParameterListsIdentical(symbol) {
62975             if (symbol.declarations.length === 1) {
62976                 return;
62977             }
62978             var links = getSymbolLinks(symbol);
62979             if (!links.typeParametersChecked) {
62980                 links.typeParametersChecked = true;
62981                 var declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol);
62982                 if (declarations.length <= 1) {
62983                     return;
62984                 }
62985                 var type = getDeclaredTypeOfSymbol(symbol);
62986                 if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) {
62987                     var name = symbolToString(symbol);
62988                     for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
62989                         var declaration = declarations_6[_i];
62990                         error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name);
62991                     }
62992                 }
62993             }
62994         }
62995         function areTypeParametersIdentical(declarations, targetParameters) {
62996             var maxTypeArgumentCount = ts.length(targetParameters);
62997             var minTypeArgumentCount = getMinTypeArgumentCount(targetParameters);
62998             for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
62999                 var declaration = declarations_7[_i];
63000                 var sourceParameters = ts.getEffectiveTypeParameterDeclarations(declaration);
63001                 var numTypeParameters = sourceParameters.length;
63002                 if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) {
63003                     return false;
63004                 }
63005                 for (var i = 0; i < numTypeParameters; i++) {
63006                     var source = sourceParameters[i];
63007                     var target = targetParameters[i];
63008                     if (source.name.escapedText !== target.symbol.escapedName) {
63009                         return false;
63010                     }
63011                     var constraint = ts.getEffectiveConstraintOfTypeParameter(source);
63012                     var sourceConstraint = constraint && getTypeFromTypeNode(constraint);
63013                     var targetConstraint = getConstraintOfTypeParameter(target);
63014                     if (sourceConstraint && targetConstraint && !isTypeIdenticalTo(sourceConstraint, targetConstraint)) {
63015                         return false;
63016                     }
63017                     var sourceDefault = source.default && getTypeFromTypeNode(source.default);
63018                     var targetDefault = getDefaultFromTypeParameter(target);
63019                     if (sourceDefault && targetDefault && !isTypeIdenticalTo(sourceDefault, targetDefault)) {
63020                         return false;
63021                     }
63022                 }
63023             }
63024             return true;
63025         }
63026         function checkClassExpression(node) {
63027             checkClassLikeDeclaration(node);
63028             checkNodeDeferred(node);
63029             return getTypeOfSymbol(getSymbolOfNode(node));
63030         }
63031         function checkClassExpressionDeferred(node) {
63032             ts.forEach(node.members, checkSourceElement);
63033             registerForUnusedIdentifiersCheck(node);
63034         }
63035         function checkClassDeclaration(node) {
63036             if (!node.name && !ts.hasSyntacticModifier(node, 512)) {
63037                 grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name);
63038             }
63039             checkClassLikeDeclaration(node);
63040             ts.forEach(node.members, checkSourceElement);
63041             registerForUnusedIdentifiersCheck(node);
63042         }
63043         function checkClassLikeDeclaration(node) {
63044             checkGrammarClassLikeDeclaration(node);
63045             checkDecorators(node);
63046             if (node.name) {
63047                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0);
63048                 checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
63049                 checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
63050                 if (!(node.flags & 8388608)) {
63051                     checkClassNameCollisionWithObject(node.name);
63052                 }
63053             }
63054             checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node));
63055             checkExportsOnMergedDeclarations(node);
63056             var symbol = getSymbolOfNode(node);
63057             var type = getDeclaredTypeOfSymbol(symbol);
63058             var typeWithThis = getTypeWithThisArgument(type);
63059             var staticType = getTypeOfSymbol(symbol);
63060             checkTypeParameterListsIdentical(symbol);
63061             checkFunctionOrConstructorSymbol(symbol);
63062             checkClassForDuplicateDeclarations(node);
63063             if (!(node.flags & 8388608)) {
63064                 checkClassForStaticPropertyNameConflicts(node);
63065             }
63066             var baseTypeNode = ts.getEffectiveBaseTypeNode(node);
63067             if (baseTypeNode) {
63068                 ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
63069                 if (languageVersion < 2) {
63070                     checkExternalEmitHelpers(baseTypeNode.parent, 1);
63071                 }
63072                 var extendsNode = ts.getClassExtendsHeritageElement(node);
63073                 if (extendsNode && extendsNode !== baseTypeNode) {
63074                     checkExpression(extendsNode.expression);
63075                 }
63076                 var baseTypes = getBaseTypes(type);
63077                 if (baseTypes.length && produceDiagnostics) {
63078                     var baseType_1 = baseTypes[0];
63079                     var baseConstructorType = getBaseConstructorTypeOfClass(type);
63080                     var staticBaseType = getApparentType(baseConstructorType);
63081                     checkBaseTypeAccessibility(staticBaseType, baseTypeNode);
63082                     checkSourceElement(baseTypeNode.expression);
63083                     if (ts.some(baseTypeNode.typeArguments)) {
63084                         ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
63085                         for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) {
63086                             var constructor = _a[_i];
63087                             if (!checkTypeArgumentConstraints(baseTypeNode, constructor.typeParameters)) {
63088                                 break;
63089                             }
63090                         }
63091                     }
63092                     var baseWithThis = getTypeWithThisArgument(baseType_1, type.thisType);
63093                     if (!checkTypeAssignableTo(typeWithThis, baseWithThis, undefined)) {
63094                         issueMemberSpecificError(node, typeWithThis, baseWithThis, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1);
63095                     }
63096                     else {
63097                         checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
63098                     }
63099                     if (baseConstructorType.flags & 8650752 && !isMixinConstructorType(staticType)) {
63100                         error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any);
63101                     }
63102                     if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32) && !(baseConstructorType.flags & 8650752)) {
63103                         var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode);
63104                         if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType_1); })) {
63105                             error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type);
63106                         }
63107                     }
63108                     checkKindsOfPropertyMemberOverrides(type, baseType_1);
63109                 }
63110             }
63111             var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node);
63112             if (implementedTypeNodes) {
63113                 for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) {
63114                     var typeRefNode = implementedTypeNodes_1[_b];
63115                     if (!ts.isEntityNameExpression(typeRefNode.expression)) {
63116                         error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments);
63117                     }
63118                     checkTypeReferenceNode(typeRefNode);
63119                     if (produceDiagnostics) {
63120                         var t = getReducedType(getTypeFromTypeNode(typeRefNode));
63121                         if (t !== errorType) {
63122                             if (isValidBaseType(t)) {
63123                                 var genericDiag = t.symbol && t.symbol.flags & 32 ?
63124                                     ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
63125                                     ts.Diagnostics.Class_0_incorrectly_implements_interface_1;
63126                                 var baseWithThis = getTypeWithThisArgument(t, type.thisType);
63127                                 if (!checkTypeAssignableTo(typeWithThis, baseWithThis, undefined)) {
63128                                     issueMemberSpecificError(node, typeWithThis, baseWithThis, genericDiag);
63129                                 }
63130                             }
63131                             else {
63132                                 error(typeRefNode, ts.Diagnostics.A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members);
63133                             }
63134                         }
63135                     }
63136                 }
63137             }
63138             if (produceDiagnostics) {
63139                 checkIndexConstraints(type);
63140                 checkTypeForDuplicateIndexSignatures(node);
63141                 checkPropertyInitialization(node);
63142             }
63143         }
63144         function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
63145             var issuedMemberError = false;
63146             var _loop_23 = function (member) {
63147                 if (ts.hasStaticModifier(member)) {
63148                     return "continue";
63149                 }
63150                 var declaredProp = member.name && getSymbolAtLocation(member.name) || getSymbolAtLocation(member);
63151                 if (declaredProp) {
63152                     var prop = getPropertyOfType(typeWithThis, declaredProp.escapedName);
63153                     var baseProp = getPropertyOfType(baseWithThis, declaredProp.escapedName);
63154                     if (prop && baseProp) {
63155                         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)); };
63156                         if (!checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(baseProp), member.name || member, undefined, rootChain)) {
63157                             issuedMemberError = true;
63158                         }
63159                     }
63160                 }
63161             };
63162             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
63163                 var member = _a[_i];
63164                 _loop_23(member);
63165             }
63166             if (!issuedMemberError) {
63167                 checkTypeAssignableTo(typeWithThis, baseWithThis, node.name || node, broadDiag);
63168             }
63169         }
63170         function checkBaseTypeAccessibility(type, node) {
63171             var signatures = getSignaturesOfType(type, 1);
63172             if (signatures.length) {
63173                 var declaration = signatures[0].declaration;
63174                 if (declaration && ts.hasEffectiveModifier(declaration, 8)) {
63175                     var typeClassDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol);
63176                     if (!isNodeWithinClass(node, typeClassDeclaration)) {
63177                         error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol));
63178                     }
63179                 }
63180             }
63181         }
63182         function getTargetSymbol(s) {
63183             return ts.getCheckFlags(s) & 1 ? s.target : s;
63184         }
63185         function getClassOrInterfaceDeclarationsOfSymbol(symbol) {
63186             return ts.filter(symbol.declarations, function (d) {
63187                 return d.kind === 252 || d.kind === 253;
63188             });
63189         }
63190         function checkKindsOfPropertyMemberOverrides(type, baseType) {
63191             var baseProperties = getPropertiesOfType(baseType);
63192             basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
63193                 var baseProperty = baseProperties_1[_i];
63194                 var base = getTargetSymbol(baseProperty);
63195                 if (base.flags & 4194304) {
63196                     continue;
63197                 }
63198                 var baseSymbol = getPropertyOfObjectType(type, base.escapedName);
63199                 if (!baseSymbol) {
63200                     continue;
63201                 }
63202                 var derived = getTargetSymbol(baseSymbol);
63203                 var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base);
63204                 ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration.");
63205                 if (derived === base) {
63206                     var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol);
63207                     if (baseDeclarationFlags & 128 && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128))) {
63208                         for (var _a = 0, _b = getBaseTypes(type); _a < _b.length; _a++) {
63209                             var otherBaseType = _b[_a];
63210                             if (otherBaseType === baseType)
63211                                 continue;
63212                             var baseSymbol_1 = getPropertyOfObjectType(otherBaseType, base.escapedName);
63213                             var derivedElsewhere = baseSymbol_1 && getTargetSymbol(baseSymbol_1);
63214                             if (derivedElsewhere && derivedElsewhere !== base) {
63215                                 continue basePropertyCheck;
63216                             }
63217                         }
63218                         if (derivedClassDecl.kind === 221) {
63219                             error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType));
63220                         }
63221                         else {
63222                             error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType));
63223                         }
63224                     }
63225                 }
63226                 else {
63227                     var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived);
63228                     if (baseDeclarationFlags & 8 || derivedDeclarationFlags & 8) {
63229                         continue;
63230                     }
63231                     var errorMessage = void 0;
63232                     var basePropertyFlags = base.flags & 98308;
63233                     var derivedPropertyFlags = derived.flags & 98308;
63234                     if (basePropertyFlags && derivedPropertyFlags) {
63235                         if (baseDeclarationFlags & 128 && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer)
63236                             || base.valueDeclaration && base.valueDeclaration.parent.kind === 253
63237                             || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) {
63238                             continue;
63239                         }
63240                         var overriddenInstanceProperty = basePropertyFlags !== 4 && derivedPropertyFlags === 4;
63241                         var overriddenInstanceAccessor = basePropertyFlags === 4 && derivedPropertyFlags !== 4;
63242                         if (overriddenInstanceProperty || overriddenInstanceAccessor) {
63243                             var errorMessage_1 = overriddenInstanceProperty ?
63244                                 ts.Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property :
63245                                 ts.Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor;
63246                             error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type));
63247                         }
63248                         else if (compilerOptions.useDefineForClassFields) {
63249                             var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 163 && !d.initializer; });
63250                             if (uninitialized
63251                                 && !(derived.flags & 33554432)
63252                                 && !(baseDeclarationFlags & 128)
63253                                 && !(derivedDeclarationFlags & 128)
63254                                 && !derived.declarations.some(function (d) { return !!(d.flags & 8388608); })) {
63255                                 var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol));
63256                                 var propName = uninitialized.name;
63257                                 if (uninitialized.exclamationToken
63258                                     || !constructor
63259                                     || !ts.isIdentifier(propName)
63260                                     || !strictNullChecks
63261                                     || !isPropertyInitializedInConstructor(propName, type, constructor)) {
63262                                     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;
63263                                     error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_2, symbolToString(base), typeToString(baseType));
63264                                 }
63265                             }
63266                         }
63267                         continue;
63268                     }
63269                     else if (isPrototypeProperty(base)) {
63270                         if (isPrototypeProperty(derived) || derived.flags & 4) {
63271                             continue;
63272                         }
63273                         else {
63274                             ts.Debug.assert(!!(derived.flags & 98304));
63275                             errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor;
63276                         }
63277                     }
63278                     else if (base.flags & 98304) {
63279                         errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function;
63280                     }
63281                     else {
63282                         errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function;
63283                     }
63284                     error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type));
63285                 }
63286             }
63287         }
63288         function getNonInterhitedProperties(type, baseTypes, properties) {
63289             if (!ts.length(baseTypes)) {
63290                 return properties;
63291             }
63292             var seen = new ts.Map();
63293             ts.forEach(properties, function (p) { seen.set(p.escapedName, p); });
63294             for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) {
63295                 var base = baseTypes_2[_i];
63296                 var properties_5 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
63297                 for (var _a = 0, properties_4 = properties_5; _a < properties_4.length; _a++) {
63298                     var prop = properties_4[_a];
63299                     var existing = seen.get(prop.escapedName);
63300                     if (existing && !isPropertyIdenticalTo(existing, prop)) {
63301                         seen.delete(prop.escapedName);
63302                     }
63303                 }
63304             }
63305             return ts.arrayFrom(seen.values());
63306         }
63307         function checkInheritedPropertiesAreIdentical(type, typeNode) {
63308             var baseTypes = getBaseTypes(type);
63309             if (baseTypes.length < 2) {
63310                 return true;
63311             }
63312             var seen = new ts.Map();
63313             ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen.set(p.escapedName, { prop: p, containingType: type }); });
63314             var ok = true;
63315             for (var _i = 0, baseTypes_3 = baseTypes; _i < baseTypes_3.length; _i++) {
63316                 var base = baseTypes_3[_i];
63317                 var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
63318                 for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) {
63319                     var prop = properties_6[_a];
63320                     var existing = seen.get(prop.escapedName);
63321                     if (!existing) {
63322                         seen.set(prop.escapedName, { prop: prop, containingType: base });
63323                     }
63324                     else {
63325                         var isInheritedProperty = existing.containingType !== type;
63326                         if (isInheritedProperty && !isPropertyIdenticalTo(existing.prop, prop)) {
63327                             ok = false;
63328                             var typeName1 = typeToString(existing.containingType);
63329                             var typeName2 = typeToString(base);
63330                             var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Named_property_0_of_types_1_and_2_are_not_identical, symbolToString(prop), typeName1, typeName2);
63331                             errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2, typeToString(type), typeName1, typeName2);
63332                             diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(typeNode, errorInfo));
63333                         }
63334                     }
63335                 }
63336             }
63337             return ok;
63338         }
63339         function checkPropertyInitialization(node) {
63340             if (!strictNullChecks || !strictPropertyInitialization || node.flags & 8388608) {
63341                 return;
63342             }
63343             var constructor = findConstructorDeclaration(node);
63344             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
63345                 var member = _a[_i];
63346                 if (ts.getEffectiveModifierFlags(member) & 2) {
63347                     continue;
63348                 }
63349                 if (isInstancePropertyWithoutInitializer(member)) {
63350                     var propName = member.name;
63351                     if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName)) {
63352                         var type = getTypeOfSymbol(getSymbolOfNode(member));
63353                         if (!(type.flags & 3 || getFalsyFlags(type) & 32768)) {
63354                             if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) {
63355                                 error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName));
63356                             }
63357                         }
63358                     }
63359                 }
63360             }
63361         }
63362         function isInstancePropertyWithoutInitializer(node) {
63363             return node.kind === 163 &&
63364                 !ts.hasSyntacticModifier(node, 32 | 128) &&
63365                 !node.exclamationToken &&
63366                 !node.initializer;
63367         }
63368         function isPropertyInitializedInConstructor(propName, propType, constructor) {
63369             var reference = ts.factory.createPropertyAccessExpression(ts.factory.createThis(), propName);
63370             ts.setParent(reference.expression, reference);
63371             ts.setParent(reference, constructor);
63372             reference.flowNode = constructor.returnFlowNode;
63373             var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
63374             return !(getFalsyFlags(flowType) & 32768);
63375         }
63376         function checkInterfaceDeclaration(node) {
63377             if (!checkGrammarDecoratorsAndModifiers(node))
63378                 checkGrammarInterfaceDeclaration(node);
63379             checkTypeParameters(node.typeParameters);
63380             if (produceDiagnostics) {
63381                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0);
63382                 checkExportsOnMergedDeclarations(node);
63383                 var symbol = getSymbolOfNode(node);
63384                 checkTypeParameterListsIdentical(symbol);
63385                 var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 253);
63386                 if (node === firstInterfaceDecl) {
63387                     var type = getDeclaredTypeOfSymbol(symbol);
63388                     var typeWithThis = getTypeWithThisArgument(type);
63389                     if (checkInheritedPropertiesAreIdentical(type, node.name)) {
63390                         for (var _i = 0, _a = getBaseTypes(type); _i < _a.length; _i++) {
63391                             var baseType = _a[_i];
63392                             checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1);
63393                         }
63394                         checkIndexConstraints(type);
63395                     }
63396                 }
63397                 checkObjectTypeForDuplicateDeclarations(node);
63398             }
63399             ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) {
63400                 if (!ts.isEntityNameExpression(heritageElement.expression)) {
63401                     error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments);
63402                 }
63403                 checkTypeReferenceNode(heritageElement);
63404             });
63405             ts.forEach(node.members, checkSourceElement);
63406             if (produceDiagnostics) {
63407                 checkTypeForDuplicateIndexSignatures(node);
63408                 registerForUnusedIdentifiersCheck(node);
63409             }
63410         }
63411         function checkTypeAliasDeclaration(node) {
63412             checkGrammarDecoratorsAndModifiers(node);
63413             checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0);
63414             checkExportsOnMergedDeclarations(node);
63415             checkTypeParameters(node.typeParameters);
63416             if (node.type.kind === 136) {
63417                 if (!intrinsicTypeKinds.has(node.name.escapedText) || ts.length(node.typeParameters) !== 1) {
63418                     error(node.type, ts.Diagnostics.The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types);
63419                 }
63420             }
63421             else {
63422                 checkSourceElement(node.type);
63423                 registerForUnusedIdentifiersCheck(node);
63424             }
63425         }
63426         function computeEnumMemberValues(node) {
63427             var nodeLinks = getNodeLinks(node);
63428             if (!(nodeLinks.flags & 16384)) {
63429                 nodeLinks.flags |= 16384;
63430                 var autoValue = 0;
63431                 for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
63432                     var member = _a[_i];
63433                     var value = computeMemberValue(member, autoValue);
63434                     getNodeLinks(member).enumMemberValue = value;
63435                     autoValue = typeof value === "number" ? value + 1 : undefined;
63436                 }
63437             }
63438         }
63439         function computeMemberValue(member, autoValue) {
63440             if (ts.isComputedNonLiteralName(member.name)) {
63441                 error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums);
63442             }
63443             else {
63444                 var text = ts.getTextOfPropertyName(member.name);
63445                 if (isNumericLiteralName(text) && !isInfinityOrNaNString(text)) {
63446                     error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name);
63447                 }
63448             }
63449             if (member.initializer) {
63450                 return computeConstantValue(member);
63451             }
63452             if (member.parent.flags & 8388608 && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0) {
63453                 return undefined;
63454             }
63455             if (autoValue !== undefined) {
63456                 return autoValue;
63457             }
63458             error(member.name, ts.Diagnostics.Enum_member_must_have_initializer);
63459             return undefined;
63460         }
63461         function computeConstantValue(member) {
63462             var enumKind = getEnumKind(getSymbolOfNode(member.parent));
63463             var isConstEnum = ts.isEnumConst(member.parent);
63464             var initializer = member.initializer;
63465             var value = enumKind === 1 && !isLiteralEnumMember(member) ? undefined : evaluate(initializer);
63466             if (value !== undefined) {
63467                 if (isConstEnum && typeof value === "number" && !isFinite(value)) {
63468                     error(initializer, isNaN(value) ?
63469                         ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN :
63470                         ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value);
63471                 }
63472             }
63473             else if (enumKind === 1) {
63474                 error(initializer, ts.Diagnostics.Computed_values_are_not_permitted_in_an_enum_with_string_valued_members);
63475                 return 0;
63476             }
63477             else if (isConstEnum) {
63478                 error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values);
63479             }
63480             else if (member.parent.flags & 8388608) {
63481                 error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression);
63482             }
63483             else {
63484                 var source = checkExpression(initializer);
63485                 if (!isTypeAssignableToKind(source, 296)) {
63486                     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));
63487                 }
63488                 else {
63489                     checkTypeAssignableTo(source, getDeclaredTypeOfSymbol(getSymbolOfNode(member.parent)), initializer, undefined);
63490                 }
63491             }
63492             return value;
63493             function evaluate(expr) {
63494                 switch (expr.kind) {
63495                     case 214:
63496                         var value_2 = evaluate(expr.operand);
63497                         if (typeof value_2 === "number") {
63498                             switch (expr.operator) {
63499                                 case 39: return value_2;
63500                                 case 40: return -value_2;
63501                                 case 54: return ~value_2;
63502                             }
63503                         }
63504                         break;
63505                     case 216:
63506                         var left = evaluate(expr.left);
63507                         var right = evaluate(expr.right);
63508                         if (typeof left === "number" && typeof right === "number") {
63509                             switch (expr.operatorToken.kind) {
63510                                 case 51: return left | right;
63511                                 case 50: return left & right;
63512                                 case 48: return left >> right;
63513                                 case 49: return left >>> right;
63514                                 case 47: return left << right;
63515                                 case 52: return left ^ right;
63516                                 case 41: return left * right;
63517                                 case 43: return left / right;
63518                                 case 39: return left + right;
63519                                 case 40: return left - right;
63520                                 case 44: return left % right;
63521                                 case 42: return Math.pow(left, right);
63522                             }
63523                         }
63524                         else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39) {
63525                             return left + right;
63526                         }
63527                         break;
63528                     case 10:
63529                     case 14:
63530                         return expr.text;
63531                     case 8:
63532                         checkGrammarNumericLiteral(expr);
63533                         return +expr.text;
63534                     case 207:
63535                         return evaluate(expr.expression);
63536                     case 78:
63537                         var identifier = expr;
63538                         if (isInfinityOrNaNString(identifier.escapedText)) {
63539                             return +(identifier.escapedText);
63540                         }
63541                         return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText);
63542                     case 202:
63543                     case 201:
63544                         var ex = expr;
63545                         if (isConstantMemberAccess(ex)) {
63546                             var type = getTypeOfExpression(ex.expression);
63547                             if (type.symbol && type.symbol.flags & 384) {
63548                                 var name = void 0;
63549                                 if (ex.kind === 201) {
63550                                     name = ex.name.escapedText;
63551                                 }
63552                                 else {
63553                                     name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text);
63554                                 }
63555                                 return evaluateEnumMember(expr, type.symbol, name);
63556                             }
63557                         }
63558                         break;
63559                 }
63560                 return undefined;
63561             }
63562             function evaluateEnumMember(expr, enumSymbol, name) {
63563                 var memberSymbol = enumSymbol.exports.get(name);
63564                 if (memberSymbol) {
63565                     var declaration = memberSymbol.valueDeclaration;
63566                     if (declaration !== member) {
63567                         if (isBlockScopedNameDeclaredBeforeUse(declaration, member)) {
63568                             return getEnumMemberValue(declaration);
63569                         }
63570                         error(expr, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
63571                         return 0;
63572                     }
63573                     else {
63574                         error(expr, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(memberSymbol));
63575                     }
63576                 }
63577                 return undefined;
63578             }
63579         }
63580         function isConstantMemberAccess(node) {
63581             return node.kind === 78 ||
63582                 node.kind === 201 && isConstantMemberAccess(node.expression) ||
63583                 node.kind === 202 && isConstantMemberAccess(node.expression) &&
63584                     ts.isStringLiteralLike(node.argumentExpression);
63585         }
63586         function checkEnumDeclaration(node) {
63587             if (!produceDiagnostics) {
63588                 return;
63589             }
63590             checkGrammarDecoratorsAndModifiers(node);
63591             checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0);
63592             checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
63593             checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
63594             checkExportsOnMergedDeclarations(node);
63595             node.members.forEach(checkEnumMember);
63596             computeEnumMemberValues(node);
63597             var enumSymbol = getSymbolOfNode(node);
63598             var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind);
63599             if (node === firstDeclaration) {
63600                 if (enumSymbol.declarations.length > 1) {
63601                     var enumIsConst_1 = ts.isEnumConst(node);
63602                     ts.forEach(enumSymbol.declarations, function (decl) {
63603                         if (ts.isEnumDeclaration(decl) && ts.isEnumConst(decl) !== enumIsConst_1) {
63604                             error(ts.getNameOfDeclaration(decl), ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const);
63605                         }
63606                     });
63607                 }
63608                 var seenEnumMissingInitialInitializer_1 = false;
63609                 ts.forEach(enumSymbol.declarations, function (declaration) {
63610                     if (declaration.kind !== 255) {
63611                         return false;
63612                     }
63613                     var enumDeclaration = declaration;
63614                     if (!enumDeclaration.members.length) {
63615                         return false;
63616                     }
63617                     var firstEnumMember = enumDeclaration.members[0];
63618                     if (!firstEnumMember.initializer) {
63619                         if (seenEnumMissingInitialInitializer_1) {
63620                             error(firstEnumMember.name, ts.Diagnostics.In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element);
63621                         }
63622                         else {
63623                             seenEnumMissingInitialInitializer_1 = true;
63624                         }
63625                     }
63626                 });
63627             }
63628         }
63629         function checkEnumMember(node) {
63630             if (ts.isPrivateIdentifier(node.name)) {
63631                 error(node, ts.Diagnostics.An_enum_member_cannot_be_named_with_a_private_identifier);
63632             }
63633         }
63634         function getFirstNonAmbientClassOrFunctionDeclaration(symbol) {
63635             var declarations = symbol.declarations;
63636             for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
63637                 var declaration = declarations_8[_i];
63638                 if ((declaration.kind === 252 ||
63639                     (declaration.kind === 251 && ts.nodeIsPresent(declaration.body))) &&
63640                     !(declaration.flags & 8388608)) {
63641                     return declaration;
63642                 }
63643             }
63644             return undefined;
63645         }
63646         function inSameLexicalScope(node1, node2) {
63647             var container1 = ts.getEnclosingBlockScopeContainer(node1);
63648             var container2 = ts.getEnclosingBlockScopeContainer(node2);
63649             if (isGlobalSourceFile(container1)) {
63650                 return isGlobalSourceFile(container2);
63651             }
63652             else if (isGlobalSourceFile(container2)) {
63653                 return false;
63654             }
63655             else {
63656                 return container1 === container2;
63657             }
63658         }
63659         function checkModuleDeclaration(node) {
63660             if (produceDiagnostics) {
63661                 var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node);
63662                 var inAmbientContext = node.flags & 8388608;
63663                 if (isGlobalAugmentation && !inAmbientContext) {
63664                     error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context);
63665                 }
63666                 var isAmbientExternalModule = ts.isAmbientModule(node);
63667                 var contextErrorMessage = isAmbientExternalModule
63668                     ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file
63669                     : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module;
63670                 if (checkGrammarModuleElementContext(node, contextErrorMessage)) {
63671                     return;
63672                 }
63673                 if (!checkGrammarDecoratorsAndModifiers(node)) {
63674                     if (!inAmbientContext && node.name.kind === 10) {
63675                         grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names);
63676                     }
63677                 }
63678                 if (ts.isIdentifier(node.name)) {
63679                     checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
63680                     checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
63681                 }
63682                 checkExportsOnMergedDeclarations(node);
63683                 var symbol = getSymbolOfNode(node);
63684                 if (symbol.flags & 512
63685                     && !inAmbientContext
63686                     && symbol.declarations.length > 1
63687                     && isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules)) {
63688                     var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol);
63689                     if (firstNonAmbientClassOrFunc) {
63690                         if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) {
63691                             error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged);
63692                         }
63693                         else if (node.pos < firstNonAmbientClassOrFunc.pos) {
63694                             error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged);
63695                         }
63696                     }
63697                     var mergedClass = ts.getDeclarationOfKind(symbol, 252);
63698                     if (mergedClass &&
63699                         inSameLexicalScope(node, mergedClass)) {
63700                         getNodeLinks(node).flags |= 32768;
63701                     }
63702                 }
63703                 if (isAmbientExternalModule) {
63704                     if (ts.isExternalModuleAugmentation(node)) {
63705                         var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432);
63706                         if (checkBody && node.body) {
63707                             for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
63708                                 var statement = _a[_i];
63709                                 checkModuleAugmentationElement(statement, isGlobalAugmentation);
63710                             }
63711                         }
63712                     }
63713                     else if (isGlobalSourceFile(node.parent)) {
63714                         if (isGlobalAugmentation) {
63715                             error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations);
63716                         }
63717                         else if (ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(node.name))) {
63718                             error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name);
63719                         }
63720                     }
63721                     else {
63722                         if (isGlobalAugmentation) {
63723                             error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations);
63724                         }
63725                         else {
63726                             error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces);
63727                         }
63728                     }
63729                 }
63730             }
63731             if (node.body) {
63732                 checkSourceElement(node.body);
63733                 if (!ts.isGlobalScopeAugmentation(node)) {
63734                     registerForUnusedIdentifiersCheck(node);
63735                 }
63736             }
63737         }
63738         function checkModuleAugmentationElement(node, isGlobalAugmentation) {
63739             switch (node.kind) {
63740                 case 232:
63741                     for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
63742                         var decl = _a[_i];
63743                         checkModuleAugmentationElement(decl, isGlobalAugmentation);
63744                     }
63745                     break;
63746                 case 266:
63747                 case 267:
63748                     grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations);
63749                     break;
63750                 case 260:
63751                 case 261:
63752                     grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module);
63753                     break;
63754                 case 198:
63755                 case 249:
63756                     var name = node.name;
63757                     if (ts.isBindingPattern(name)) {
63758                         for (var _b = 0, _c = name.elements; _b < _c.length; _b++) {
63759                             var el = _c[_b];
63760                             checkModuleAugmentationElement(el, isGlobalAugmentation);
63761                         }
63762                         break;
63763                     }
63764                 case 252:
63765                 case 255:
63766                 case 251:
63767                 case 253:
63768                 case 256:
63769                 case 254:
63770                     if (isGlobalAugmentation) {
63771                         return;
63772                     }
63773                     var symbol = getSymbolOfNode(node);
63774                     if (symbol) {
63775                         var reportError = !(symbol.flags & 33554432);
63776                         if (!reportError) {
63777                             reportError = !!symbol.parent && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]);
63778                         }
63779                     }
63780                     break;
63781             }
63782         }
63783         function getFirstNonModuleExportsIdentifier(node) {
63784             switch (node.kind) {
63785                 case 78:
63786                     return node;
63787                 case 157:
63788                     do {
63789                         node = node.left;
63790                     } while (node.kind !== 78);
63791                     return node;
63792                 case 201:
63793                     do {
63794                         if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) {
63795                             return node.name;
63796                         }
63797                         node = node.expression;
63798                     } while (node.kind !== 78);
63799                     return node;
63800             }
63801         }
63802         function checkExternalImportOrExportDeclaration(node) {
63803             var moduleName = ts.getExternalModuleName(node);
63804             if (!moduleName || ts.nodeIsMissing(moduleName)) {
63805                 return false;
63806             }
63807             if (!ts.isStringLiteral(moduleName)) {
63808                 error(moduleName, ts.Diagnostics.String_literal_expected);
63809                 return false;
63810             }
63811             var inAmbientExternalModule = node.parent.kind === 257 && ts.isAmbientModule(node.parent.parent);
63812             if (node.parent.kind !== 297 && !inAmbientExternalModule) {
63813                 error(moduleName, node.kind === 267 ?
63814                     ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace :
63815                     ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module);
63816                 return false;
63817             }
63818             if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) {
63819                 if (!isTopLevelInExternalModuleAugmentation(node)) {
63820                     error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name);
63821                     return false;
63822                 }
63823             }
63824             return true;
63825         }
63826         function checkAliasSymbol(node) {
63827             var symbol = getSymbolOfNode(node);
63828             var target = resolveAlias(symbol);
63829             if (target !== unknownSymbol) {
63830                 symbol = getMergedSymbol(symbol.exportSymbol || symbol);
63831                 var excludedMeanings = (symbol.flags & (111551 | 1048576) ? 111551 : 0) |
63832                     (symbol.flags & 788968 ? 788968 : 0) |
63833                     (symbol.flags & 1920 ? 1920 : 0);
63834                 if (target.flags & excludedMeanings) {
63835                     var message = node.kind === 270 ?
63836                         ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 :
63837                         ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
63838                     error(node, message, symbolToString(symbol));
63839                 }
63840                 if (compilerOptions.isolatedModules
63841                     && node.kind === 270
63842                     && !node.parent.parent.isTypeOnly
63843                     && !(target.flags & 111551)
63844                     && !(node.flags & 8388608)) {
63845                     error(node, ts.Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type);
63846                 }
63847                 if (ts.isImportSpecifier(node) && ts.every(target.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728); })) {
63848                     errorOrSuggestion(false, node.name, ts.Diagnostics._0_is_deprecated, symbol.escapedName);
63849                 }
63850             }
63851         }
63852         function checkImportBinding(node) {
63853             checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
63854             checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
63855             checkAliasSymbol(node);
63856             if (node.kind === 265 &&
63857                 ts.idText(node.propertyName || node.name) === "default" &&
63858                 compilerOptions.esModuleInterop &&
63859                 moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) {
63860                 checkExternalEmitHelpers(node, 262144);
63861             }
63862         }
63863         function checkImportDeclaration(node) {
63864             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
63865                 return;
63866             }
63867             if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasEffectiveModifiers(node)) {
63868                 grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers);
63869             }
63870             if (checkExternalImportOrExportDeclaration(node)) {
63871                 var importClause = node.importClause;
63872                 if (importClause && !checkGrammarImportClause(importClause)) {
63873                     if (importClause.name) {
63874                         checkImportBinding(importClause);
63875                     }
63876                     if (importClause.namedBindings) {
63877                         if (importClause.namedBindings.kind === 263) {
63878                             checkImportBinding(importClause.namedBindings);
63879                             if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015 && compilerOptions.esModuleInterop) {
63880                                 checkExternalEmitHelpers(node, 131072);
63881                             }
63882                         }
63883                         else {
63884                             var moduleExisted = resolveExternalModuleName(node, node.moduleSpecifier);
63885                             if (moduleExisted) {
63886                                 ts.forEach(importClause.namedBindings.elements, checkImportBinding);
63887                             }
63888                         }
63889                     }
63890                 }
63891             }
63892         }
63893         function checkImportEqualsDeclaration(node) {
63894             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
63895                 return;
63896             }
63897             checkGrammarDecoratorsAndModifiers(node);
63898             if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) {
63899                 checkImportBinding(node);
63900                 if (ts.hasSyntacticModifier(node, 1)) {
63901                     markExportAsReferenced(node);
63902                 }
63903                 if (node.moduleReference.kind !== 272) {
63904                     var target = resolveAlias(getSymbolOfNode(node));
63905                     if (target !== unknownSymbol) {
63906                         if (target.flags & 111551) {
63907                             var moduleName = ts.getFirstIdentifier(node.moduleReference);
63908                             if (!(resolveEntityName(moduleName, 111551 | 1920).flags & 1920)) {
63909                                 error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName));
63910                             }
63911                         }
63912                         if (target.flags & 788968) {
63913                             checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0);
63914                         }
63915                     }
63916                 }
63917                 else {
63918                     if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 8388608)) {
63919                         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);
63920                     }
63921                 }
63922             }
63923         }
63924         function checkExportDeclaration(node) {
63925             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) {
63926                 return;
63927             }
63928             if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasEffectiveModifiers(node)) {
63929                 grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers);
63930             }
63931             if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0) {
63932                 checkExternalEmitHelpers(node, 4194304);
63933             }
63934             checkGrammarExportDeclaration(node);
63935             if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) {
63936                 if (node.exportClause && !ts.isNamespaceExport(node.exportClause)) {
63937                     ts.forEach(node.exportClause.elements, checkExportSpecifier);
63938                     var inAmbientExternalModule = node.parent.kind === 257 && ts.isAmbientModule(node.parent.parent);
63939                     var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 257 &&
63940                         !node.moduleSpecifier && node.flags & 8388608;
63941                     if (node.parent.kind !== 297 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) {
63942                         error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace);
63943                     }
63944                 }
63945                 else {
63946                     var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier);
63947                     if (moduleSymbol && hasExportAssignmentSymbol(moduleSymbol)) {
63948                         error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol));
63949                     }
63950                     else if (node.exportClause) {
63951                         checkAliasSymbol(node.exportClause);
63952                     }
63953                     if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) {
63954                         if (node.exportClause) {
63955                             if (compilerOptions.esModuleInterop) {
63956                                 checkExternalEmitHelpers(node, 131072);
63957                             }
63958                         }
63959                         else {
63960                             checkExternalEmitHelpers(node, 65536);
63961                         }
63962                     }
63963                 }
63964             }
63965         }
63966         function checkGrammarExportDeclaration(node) {
63967             var _a;
63968             var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 268;
63969             if (isTypeOnlyExportStar) {
63970                 grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type);
63971             }
63972             return !isTypeOnlyExportStar;
63973         }
63974         function checkGrammarModuleElementContext(node, errorMessage) {
63975             var isInAppropriateContext = node.parent.kind === 297 || node.parent.kind === 257 || node.parent.kind === 256;
63976             if (!isInAppropriateContext) {
63977                 grammarErrorOnFirstToken(node, errorMessage);
63978             }
63979             return !isInAppropriateContext;
63980         }
63981         function importClauseContainsReferencedImport(importClause) {
63982             return ts.forEachImportClauseDeclaration(importClause, function (declaration) {
63983                 return !!getSymbolOfNode(declaration).isReferenced;
63984             });
63985         }
63986         function importClauseContainsConstEnumUsedAsValue(importClause) {
63987             return ts.forEachImportClauseDeclaration(importClause, function (declaration) {
63988                 return !!getSymbolLinks(getSymbolOfNode(declaration)).constEnumReferenced;
63989             });
63990         }
63991         function checkImportsForTypeOnlyConversion(sourceFile) {
63992             for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
63993                 var statement = _a[_i];
63994                 if (ts.isImportDeclaration(statement) &&
63995                     statement.importClause &&
63996                     !statement.importClause.isTypeOnly &&
63997                     importClauseContainsReferencedImport(statement.importClause) &&
63998                     !isReferencedAliasDeclaration(statement.importClause, true) &&
63999                     !importClauseContainsConstEnumUsedAsValue(statement.importClause)) {
64000                     error(statement, ts.Diagnostics.This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is_set_to_error);
64001                 }
64002             }
64003         }
64004         function checkExportSpecifier(node) {
64005             checkAliasSymbol(node);
64006             if (ts.getEmitDeclarations(compilerOptions)) {
64007                 collectLinkedAliases(node.propertyName || node.name, true);
64008             }
64009             if (!node.parent.parent.moduleSpecifier) {
64010                 var exportedName = node.propertyName || node.name;
64011                 var symbol = resolveName(exportedName, exportedName.escapedText, 111551 | 788968 | 1920 | 2097152, undefined, undefined, true);
64012                 if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) {
64013                     error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName));
64014                 }
64015                 else {
64016                     markExportAsReferenced(node);
64017                     var target = symbol && (symbol.flags & 2097152 ? resolveAlias(symbol) : symbol);
64018                     if (!target || target === unknownSymbol || target.flags & 111551) {
64019                         checkExpressionCached(node.propertyName || node.name);
64020                     }
64021                 }
64022             }
64023             else {
64024                 if (compilerOptions.esModuleInterop &&
64025                     moduleKind !== ts.ModuleKind.System &&
64026                     moduleKind < ts.ModuleKind.ES2015 &&
64027                     ts.idText(node.propertyName || node.name) === "default") {
64028                     checkExternalEmitHelpers(node, 262144);
64029                 }
64030             }
64031         }
64032         function checkExportAssignment(node) {
64033             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) {
64034                 return;
64035             }
64036             var container = node.parent.kind === 297 ? node.parent : node.parent.parent;
64037             if (container.kind === 256 && !ts.isAmbientModule(container)) {
64038                 if (node.isExportEquals) {
64039                     error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace);
64040                 }
64041                 else {
64042                     error(node, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module);
64043                 }
64044                 return;
64045             }
64046             if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasEffectiveModifiers(node)) {
64047                 grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers);
64048             }
64049             if (node.expression.kind === 78) {
64050                 var id = node.expression;
64051                 var sym = resolveEntityName(id, 67108863, true, true, node);
64052                 if (sym) {
64053                     markAliasReferenced(sym, id);
64054                     var target = sym.flags & 2097152 ? resolveAlias(sym) : sym;
64055                     if (target === unknownSymbol || target.flags & 111551) {
64056                         checkExpressionCached(node.expression);
64057                     }
64058                 }
64059                 else {
64060                     checkExpressionCached(node.expression);
64061                 }
64062                 if (ts.getEmitDeclarations(compilerOptions)) {
64063                     collectLinkedAliases(node.expression, true);
64064                 }
64065             }
64066             else {
64067                 checkExpressionCached(node.expression);
64068             }
64069             checkExternalModuleExports(container);
64070             if ((node.flags & 8388608) && !ts.isEntityNameExpression(node.expression)) {
64071                 grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
64072             }
64073             if (node.isExportEquals && !(node.flags & 8388608)) {
64074                 if (moduleKind >= ts.ModuleKind.ES2015) {
64075                     grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
64076                 }
64077                 else if (moduleKind === ts.ModuleKind.System) {
64078                     grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system);
64079                 }
64080             }
64081         }
64082         function hasExportedMembers(moduleSymbol) {
64083             return ts.forEachEntry(moduleSymbol.exports, function (_, id) { return id !== "export="; });
64084         }
64085         function checkExternalModuleExports(node) {
64086             var moduleSymbol = getSymbolOfNode(node);
64087             var links = getSymbolLinks(moduleSymbol);
64088             if (!links.exportsChecked) {
64089                 var exportEqualsSymbol = moduleSymbol.exports.get("export=");
64090                 if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) {
64091                     var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration;
64092                     if (!isTopLevelInExternalModuleAugmentation(declaration) && !ts.isInJSFile(declaration)) {
64093                         error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements);
64094                     }
64095                 }
64096                 var exports_2 = getExportsOfModule(moduleSymbol);
64097                 if (exports_2) {
64098                     exports_2.forEach(function (_a, id) {
64099                         var declarations = _a.declarations, flags = _a.flags;
64100                         if (id === "__export") {
64101                             return;
64102                         }
64103                         if (flags & (1920 | 64 | 384)) {
64104                             return;
64105                         }
64106                         var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverloadAndNotAccessor);
64107                         if (flags & 524288 && exportedDeclarationsCount <= 2) {
64108                             return;
64109                         }
64110                         if (exportedDeclarationsCount > 1) {
64111                             for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) {
64112                                 var declaration = declarations_9[_i];
64113                                 if (isNotOverload(declaration)) {
64114                                     diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, ts.unescapeLeadingUnderscores(id)));
64115                                 }
64116                             }
64117                         }
64118                     });
64119                 }
64120                 links.exportsChecked = true;
64121             }
64122         }
64123         function checkSourceElement(node) {
64124             if (node) {
64125                 var saveCurrentNode = currentNode;
64126                 currentNode = node;
64127                 instantiationCount = 0;
64128                 checkSourceElementWorker(node);
64129                 currentNode = saveCurrentNode;
64130             }
64131         }
64132         function checkSourceElementWorker(node) {
64133             if (ts.isInJSFile(node)) {
64134                 ts.forEach(node.jsDoc, function (_a) {
64135                     var tags = _a.tags;
64136                     return ts.forEach(tags, checkSourceElement);
64137                 });
64138             }
64139             var kind = node.kind;
64140             if (cancellationToken) {
64141                 switch (kind) {
64142                     case 256:
64143                     case 252:
64144                     case 253:
64145                     case 251:
64146                         cancellationToken.throwIfCancellationRequested();
64147                 }
64148             }
64149             if (kind >= 232 && kind <= 248 && node.flowNode && !isReachableFlowNode(node.flowNode)) {
64150                 errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected);
64151             }
64152             switch (kind) {
64153                 case 159:
64154                     return checkTypeParameter(node);
64155                 case 160:
64156                     return checkParameter(node);
64157                 case 163:
64158                     return checkPropertyDeclaration(node);
64159                 case 162:
64160                     return checkPropertySignature(node);
64161                 case 174:
64162                 case 175:
64163                 case 169:
64164                 case 170:
64165                 case 171:
64166                     return checkSignatureDeclaration(node);
64167                 case 165:
64168                 case 164:
64169                     return checkMethodDeclaration(node);
64170                 case 166:
64171                     return checkConstructorDeclaration(node);
64172                 case 167:
64173                 case 168:
64174                     return checkAccessorDeclaration(node);
64175                 case 173:
64176                     return checkTypeReferenceNode(node);
64177                 case 172:
64178                     return checkTypePredicate(node);
64179                 case 176:
64180                     return checkTypeQuery(node);
64181                 case 177:
64182                     return checkTypeLiteral(node);
64183                 case 178:
64184                     return checkArrayType(node);
64185                 case 179:
64186                     return checkTupleType(node);
64187                 case 182:
64188                 case 183:
64189                     return checkUnionOrIntersectionType(node);
64190                 case 186:
64191                 case 180:
64192                 case 181:
64193                     return checkSourceElement(node.type);
64194                 case 187:
64195                     return checkThisType(node);
64196                 case 188:
64197                     return checkTypeOperator(node);
64198                 case 184:
64199                     return checkConditionalType(node);
64200                 case 185:
64201                     return checkInferType(node);
64202                 case 193:
64203                     return checkTemplateLiteralType(node);
64204                 case 195:
64205                     return checkImportType(node);
64206                 case 192:
64207                     return checkNamedTupleMember(node);
64208                 case 315:
64209                     return checkJSDocAugmentsTag(node);
64210                 case 316:
64211                     return checkJSDocImplementsTag(node);
64212                 case 331:
64213                 case 324:
64214                 case 325:
64215                     return checkJSDocTypeAliasTag(node);
64216                 case 330:
64217                     return checkJSDocTemplateTag(node);
64218                 case 329:
64219                     return checkJSDocTypeTag(node);
64220                 case 326:
64221                     return checkJSDocParameterTag(node);
64222                 case 333:
64223                     return checkJSDocPropertyTag(node);
64224                 case 308:
64225                     checkJSDocFunctionType(node);
64226                 case 306:
64227                 case 305:
64228                 case 303:
64229                 case 304:
64230                 case 312:
64231                     checkJSDocTypeIsInJsFile(node);
64232                     ts.forEachChild(node, checkSourceElement);
64233                     return;
64234                 case 309:
64235                     checkJSDocVariadicType(node);
64236                     return;
64237                 case 301:
64238                     return checkSourceElement(node.type);
64239                 case 189:
64240                     return checkIndexedAccessType(node);
64241                 case 190:
64242                     return checkMappedType(node);
64243                 case 251:
64244                     return checkFunctionDeclaration(node);
64245                 case 230:
64246                 case 257:
64247                     return checkBlock(node);
64248                 case 232:
64249                     return checkVariableStatement(node);
64250                 case 233:
64251                     return checkExpressionStatement(node);
64252                 case 234:
64253                     return checkIfStatement(node);
64254                 case 235:
64255                     return checkDoStatement(node);
64256                 case 236:
64257                     return checkWhileStatement(node);
64258                 case 237:
64259                     return checkForStatement(node);
64260                 case 238:
64261                     return checkForInStatement(node);
64262                 case 239:
64263                     return checkForOfStatement(node);
64264                 case 240:
64265                 case 241:
64266                     return checkBreakOrContinueStatement(node);
64267                 case 242:
64268                     return checkReturnStatement(node);
64269                 case 243:
64270                     return checkWithStatement(node);
64271                 case 244:
64272                     return checkSwitchStatement(node);
64273                 case 245:
64274                     return checkLabeledStatement(node);
64275                 case 246:
64276                     return checkThrowStatement(node);
64277                 case 247:
64278                     return checkTryStatement(node);
64279                 case 249:
64280                     return checkVariableDeclaration(node);
64281                 case 198:
64282                     return checkBindingElement(node);
64283                 case 252:
64284                     return checkClassDeclaration(node);
64285                 case 253:
64286                     return checkInterfaceDeclaration(node);
64287                 case 254:
64288                     return checkTypeAliasDeclaration(node);
64289                 case 255:
64290                     return checkEnumDeclaration(node);
64291                 case 256:
64292                     return checkModuleDeclaration(node);
64293                 case 261:
64294                     return checkImportDeclaration(node);
64295                 case 260:
64296                     return checkImportEqualsDeclaration(node);
64297                 case 267:
64298                     return checkExportDeclaration(node);
64299                 case 266:
64300                     return checkExportAssignment(node);
64301                 case 231:
64302                 case 248:
64303                     checkGrammarStatementInAmbientContext(node);
64304                     return;
64305                 case 271:
64306                     return checkMissingDeclaration(node);
64307             }
64308         }
64309         function checkJSDocTypeIsInJsFile(node) {
64310             if (!ts.isInJSFile(node)) {
64311                 grammarErrorOnNode(node, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments);
64312             }
64313         }
64314         function checkJSDocVariadicType(node) {
64315             checkJSDocTypeIsInJsFile(node);
64316             checkSourceElement(node.type);
64317             var parent = node.parent;
64318             if (ts.isParameter(parent) && ts.isJSDocFunctionType(parent.parent)) {
64319                 if (ts.last(parent.parent.parameters) !== parent) {
64320                     error(node, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
64321                 }
64322                 return;
64323             }
64324             if (!ts.isJSDocTypeExpression(parent)) {
64325                 error(node, ts.Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature);
64326             }
64327             var paramTag = node.parent.parent;
64328             if (!ts.isJSDocParameterTag(paramTag)) {
64329                 error(node, ts.Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature);
64330                 return;
64331             }
64332             var param = ts.getParameterSymbolFromJSDoc(paramTag);
64333             if (!param) {
64334                 return;
64335             }
64336             var host = ts.getHostSignatureFromJSDoc(paramTag);
64337             if (!host || ts.last(host.parameters).symbol !== param) {
64338                 error(node, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
64339             }
64340         }
64341         function getTypeFromJSDocVariadicType(node) {
64342             var type = getTypeFromTypeNode(node.type);
64343             var parent = node.parent;
64344             var paramTag = node.parent.parent;
64345             if (ts.isJSDocTypeExpression(node.parent) && ts.isJSDocParameterTag(paramTag)) {
64346                 var host_1 = ts.getHostSignatureFromJSDoc(paramTag);
64347                 if (host_1) {
64348                     var lastParamDeclaration = ts.lastOrUndefined(host_1.parameters);
64349                     var symbol = ts.getParameterSymbolFromJSDoc(paramTag);
64350                     if (!lastParamDeclaration ||
64351                         symbol && lastParamDeclaration.symbol === symbol && ts.isRestParameter(lastParamDeclaration)) {
64352                         return createArrayType(type);
64353                     }
64354                 }
64355             }
64356             if (ts.isParameter(parent) && ts.isJSDocFunctionType(parent.parent)) {
64357                 return createArrayType(type);
64358             }
64359             return addOptionality(type);
64360         }
64361         function checkNodeDeferred(node) {
64362             var enclosingFile = ts.getSourceFileOfNode(node);
64363             var links = getNodeLinks(enclosingFile);
64364             if (!(links.flags & 1)) {
64365                 links.deferredNodes = links.deferredNodes || new ts.Map();
64366                 var id = getNodeId(node);
64367                 links.deferredNodes.set(id, node);
64368             }
64369         }
64370         function checkDeferredNodes(context) {
64371             var links = getNodeLinks(context);
64372             if (links.deferredNodes) {
64373                 links.deferredNodes.forEach(checkDeferredNode);
64374             }
64375         }
64376         function checkDeferredNode(node) {
64377             var saveCurrentNode = currentNode;
64378             currentNode = node;
64379             instantiationCount = 0;
64380             switch (node.kind) {
64381                 case 203:
64382                 case 204:
64383                 case 205:
64384                 case 161:
64385                 case 275:
64386                     resolveUntypedCall(node);
64387                     break;
64388                 case 208:
64389                 case 209:
64390                 case 165:
64391                 case 164:
64392                     checkFunctionExpressionOrObjectLiteralMethodDeferred(node);
64393                     break;
64394                 case 167:
64395                 case 168:
64396                     checkAccessorDeclaration(node);
64397                     break;
64398                 case 221:
64399                     checkClassExpressionDeferred(node);
64400                     break;
64401                 case 274:
64402                     checkJsxSelfClosingElementDeferred(node);
64403                     break;
64404                 case 273:
64405                     checkJsxElementDeferred(node);
64406                     break;
64407             }
64408             currentNode = saveCurrentNode;
64409         }
64410         function checkSourceFile(node) {
64411             var tracingData = ["check", "checkSourceFile", { path: node.path }];
64412             ts.tracing.begin.apply(ts.tracing, tracingData);
64413             ts.performance.mark("beforeCheck");
64414             checkSourceFileWorker(node);
64415             ts.performance.mark("afterCheck");
64416             ts.performance.measure("Check", "beforeCheck", "afterCheck");
64417             ts.tracing.end.apply(ts.tracing, tracingData);
64418         }
64419         function unusedIsError(kind, isAmbient) {
64420             if (isAmbient) {
64421                 return false;
64422             }
64423             switch (kind) {
64424                 case 0:
64425                     return !!compilerOptions.noUnusedLocals;
64426                 case 1:
64427                     return !!compilerOptions.noUnusedParameters;
64428                 default:
64429                     return ts.Debug.assertNever(kind);
64430             }
64431         }
64432         function getPotentiallyUnusedIdentifiers(sourceFile) {
64433             return allPotentiallyUnusedIdentifiers.get(sourceFile.path) || ts.emptyArray;
64434         }
64435         function checkSourceFileWorker(node) {
64436             var links = getNodeLinks(node);
64437             if (!(links.flags & 1)) {
64438                 if (ts.skipTypeChecking(node, compilerOptions, host)) {
64439                     return;
64440                 }
64441                 checkGrammarSourceFile(node);
64442                 ts.clear(potentialThisCollisions);
64443                 ts.clear(potentialNewTargetCollisions);
64444                 ts.clear(potentialWeakMapCollisions);
64445                 ts.forEach(node.statements, checkSourceElement);
64446                 checkSourceElement(node.endOfFileToken);
64447                 checkDeferredNodes(node);
64448                 if (ts.isExternalOrCommonJsModule(node)) {
64449                     registerForUnusedIdentifiersCheck(node);
64450                 }
64451                 if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
64452                     checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) {
64453                         if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 8388608))) {
64454                             diagnostics.add(diag);
64455                         }
64456                     });
64457                 }
64458                 if (compilerOptions.importsNotUsedAsValues === 2 &&
64459                     !node.isDeclarationFile &&
64460                     ts.isExternalModule(node)) {
64461                     checkImportsForTypeOnlyConversion(node);
64462                 }
64463                 if (ts.isExternalOrCommonJsModule(node)) {
64464                     checkExternalModuleExports(node);
64465                 }
64466                 if (potentialThisCollisions.length) {
64467                     ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope);
64468                     ts.clear(potentialThisCollisions);
64469                 }
64470                 if (potentialNewTargetCollisions.length) {
64471                     ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope);
64472                     ts.clear(potentialNewTargetCollisions);
64473                 }
64474                 if (potentialWeakMapCollisions.length) {
64475                     ts.forEach(potentialWeakMapCollisions, checkWeakMapCollision);
64476                     ts.clear(potentialWeakMapCollisions);
64477                 }
64478                 links.flags |= 1;
64479             }
64480         }
64481         function getDiagnostics(sourceFile, ct) {
64482             try {
64483                 cancellationToken = ct;
64484                 return getDiagnosticsWorker(sourceFile);
64485             }
64486             finally {
64487                 cancellationToken = undefined;
64488             }
64489         }
64490         function getDiagnosticsWorker(sourceFile) {
64491             throwIfNonDiagnosticsProducing();
64492             if (sourceFile) {
64493                 var previousGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
64494                 var previousGlobalDiagnosticsSize = previousGlobalDiagnostics.length;
64495                 checkSourceFile(sourceFile);
64496                 var semanticDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
64497                 var currentGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
64498                 if (currentGlobalDiagnostics !== previousGlobalDiagnostics) {
64499                     var deferredGlobalDiagnostics = ts.relativeComplement(previousGlobalDiagnostics, currentGlobalDiagnostics, ts.compareDiagnostics);
64500                     return ts.concatenate(deferredGlobalDiagnostics, semanticDiagnostics);
64501                 }
64502                 else if (previousGlobalDiagnosticsSize === 0 && currentGlobalDiagnostics.length > 0) {
64503                     return ts.concatenate(currentGlobalDiagnostics, semanticDiagnostics);
64504                 }
64505                 return semanticDiagnostics;
64506             }
64507             ts.forEach(host.getSourceFiles(), checkSourceFile);
64508             return diagnostics.getDiagnostics();
64509         }
64510         function getGlobalDiagnostics() {
64511             throwIfNonDiagnosticsProducing();
64512             return diagnostics.getGlobalDiagnostics();
64513         }
64514         function throwIfNonDiagnosticsProducing() {
64515             if (!produceDiagnostics) {
64516                 throw new Error("Trying to get diagnostics from a type checker that does not produce them.");
64517             }
64518         }
64519         function getSymbolsInScope(location, meaning) {
64520             if (location.flags & 16777216) {
64521                 return [];
64522             }
64523             var symbols = ts.createSymbolTable();
64524             var isStatic = false;
64525             populateSymbols();
64526             symbols.delete("this");
64527             return symbolsToArray(symbols);
64528             function populateSymbols() {
64529                 while (location) {
64530                     if (location.locals && !isGlobalSourceFile(location)) {
64531                         copySymbols(location.locals, meaning);
64532                     }
64533                     switch (location.kind) {
64534                         case 297:
64535                             if (!ts.isExternalOrCommonJsModule(location))
64536                                 break;
64537                         case 256:
64538                             copySymbols(getSymbolOfNode(location).exports, meaning & 2623475);
64539                             break;
64540                         case 255:
64541                             copySymbols(getSymbolOfNode(location).exports, meaning & 8);
64542                             break;
64543                         case 221:
64544                             var className = location.name;
64545                             if (className) {
64546                                 copySymbol(location.symbol, meaning);
64547                             }
64548                         case 252:
64549                         case 253:
64550                             if (!isStatic) {
64551                                 copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968);
64552                             }
64553                             break;
64554                         case 208:
64555                             var funcName = location.name;
64556                             if (funcName) {
64557                                 copySymbol(location.symbol, meaning);
64558                             }
64559                             break;
64560                     }
64561                     if (ts.introducesArgumentsExoticObject(location)) {
64562                         copySymbol(argumentsSymbol, meaning);
64563                     }
64564                     isStatic = ts.hasSyntacticModifier(location, 32);
64565                     location = location.parent;
64566                 }
64567                 copySymbols(globals, meaning);
64568             }
64569             function copySymbol(symbol, meaning) {
64570                 if (ts.getCombinedLocalAndExportSymbolFlags(symbol) & meaning) {
64571                     var id = symbol.escapedName;
64572                     if (!symbols.has(id)) {
64573                         symbols.set(id, symbol);
64574                     }
64575                 }
64576             }
64577             function copySymbols(source, meaning) {
64578                 if (meaning) {
64579                     source.forEach(function (symbol) {
64580                         copySymbol(symbol, meaning);
64581                     });
64582                 }
64583             }
64584         }
64585         function isTypeDeclarationName(name) {
64586             return name.kind === 78 &&
64587                 isTypeDeclaration(name.parent) &&
64588                 ts.getNameOfDeclaration(name.parent) === name;
64589         }
64590         function isTypeDeclaration(node) {
64591             switch (node.kind) {
64592                 case 159:
64593                 case 252:
64594                 case 253:
64595                 case 254:
64596                 case 255:
64597                 case 331:
64598                 case 324:
64599                 case 325:
64600                     return true;
64601                 case 262:
64602                     return node.isTypeOnly;
64603                 case 265:
64604                 case 270:
64605                     return node.parent.parent.isTypeOnly;
64606                 default:
64607                     return false;
64608             }
64609         }
64610         function isTypeReferenceIdentifier(node) {
64611             while (node.parent.kind === 157) {
64612                 node = node.parent;
64613             }
64614             return node.parent.kind === 173;
64615         }
64616         function isHeritageClauseElementIdentifier(node) {
64617             while (node.parent.kind === 201) {
64618                 node = node.parent;
64619             }
64620             return node.parent.kind === 223;
64621         }
64622         function isJSDocEntryNameReference(node) {
64623             while (node.parent.kind === 157) {
64624                 node = node.parent;
64625             }
64626             while (node.parent.kind === 201) {
64627                 node = node.parent;
64628             }
64629             return node.parent.kind === 302;
64630         }
64631         function forEachEnclosingClass(node, callback) {
64632             var result;
64633             while (true) {
64634                 node = ts.getContainingClass(node);
64635                 if (!node)
64636                     break;
64637                 if (result = callback(node))
64638                     break;
64639             }
64640             return result;
64641         }
64642         function isNodeUsedDuringClassInitialization(node) {
64643             return !!ts.findAncestor(node, function (element) {
64644                 if (ts.isConstructorDeclaration(element) && ts.nodeIsPresent(element.body) || ts.isPropertyDeclaration(element)) {
64645                     return true;
64646                 }
64647                 else if (ts.isClassLike(element) || ts.isFunctionLikeDeclaration(element)) {
64648                     return "quit";
64649                 }
64650                 return false;
64651             });
64652         }
64653         function isNodeWithinClass(node, classDeclaration) {
64654             return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; });
64655         }
64656         function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) {
64657             while (nodeOnRightSide.parent.kind === 157) {
64658                 nodeOnRightSide = nodeOnRightSide.parent;
64659             }
64660             if (nodeOnRightSide.parent.kind === 260) {
64661                 return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined;
64662             }
64663             if (nodeOnRightSide.parent.kind === 266) {
64664                 return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined;
64665             }
64666             return undefined;
64667         }
64668         function isInRightSideOfImportOrExportAssignment(node) {
64669             return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined;
64670         }
64671         function getSpecialPropertyAssignmentSymbolFromEntityName(entityName) {
64672             var specialPropertyAssignmentKind = ts.getAssignmentDeclarationKind(entityName.parent.parent);
64673             switch (specialPropertyAssignmentKind) {
64674                 case 1:
64675                 case 3:
64676                     return getSymbolOfNode(entityName.parent);
64677                 case 4:
64678                 case 2:
64679                 case 5:
64680                     return getSymbolOfNode(entityName.parent.parent);
64681             }
64682         }
64683         function isImportTypeQualifierPart(node) {
64684             var parent = node.parent;
64685             while (ts.isQualifiedName(parent)) {
64686                 node = parent;
64687                 parent = parent.parent;
64688             }
64689             if (parent && parent.kind === 195 && parent.qualifier === node) {
64690                 return parent;
64691             }
64692             return undefined;
64693         }
64694         function getSymbolOfNameOrPropertyAccessExpression(name) {
64695             if (ts.isDeclarationName(name)) {
64696                 return getSymbolOfNode(name.parent);
64697             }
64698             if (ts.isInJSFile(name) &&
64699                 name.parent.kind === 201 &&
64700                 name.parent === name.parent.parent.left) {
64701                 if (!ts.isPrivateIdentifier(name)) {
64702                     var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(name);
64703                     if (specialPropertyAssignmentSymbol) {
64704                         return specialPropertyAssignmentSymbol;
64705                     }
64706                 }
64707             }
64708             if (name.parent.kind === 266 && ts.isEntityNameExpression(name)) {
64709                 var success = resolveEntityName(name, 111551 | 788968 | 1920 | 2097152, true);
64710                 if (success && success !== unknownSymbol) {
64711                     return success;
64712                 }
64713             }
64714             else if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name) && isInRightSideOfImportOrExportAssignment(name)) {
64715                 var importEqualsDeclaration = ts.getAncestor(name, 260);
64716                 ts.Debug.assert(importEqualsDeclaration !== undefined);
64717                 return getSymbolOfPartOfRightHandSideOfImportEquals(name, true);
64718             }
64719             if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name)) {
64720                 var possibleImportNode = isImportTypeQualifierPart(name);
64721                 if (possibleImportNode) {
64722                     getTypeFromTypeNode(possibleImportNode);
64723                     var sym = getNodeLinks(name).resolvedSymbol;
64724                     return sym === unknownSymbol ? undefined : sym;
64725                 }
64726             }
64727             while (ts.isRightSideOfQualifiedNameOrPropertyAccess(name)) {
64728                 name = name.parent;
64729             }
64730             if (isHeritageClauseElementIdentifier(name)) {
64731                 var meaning = 0;
64732                 if (name.parent.kind === 223) {
64733                     meaning = 788968;
64734                     if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) {
64735                         meaning |= 111551;
64736                     }
64737                 }
64738                 else {
64739                     meaning = 1920;
64740                 }
64741                 meaning |= 2097152;
64742                 var entityNameSymbol = ts.isEntityNameExpression(name) ? resolveEntityName(name, meaning) : undefined;
64743                 if (entityNameSymbol) {
64744                     return entityNameSymbol;
64745                 }
64746             }
64747             if (name.parent.kind === 326) {
64748                 return ts.getParameterSymbolFromJSDoc(name.parent);
64749             }
64750             if (name.parent.kind === 159 && name.parent.parent.kind === 330) {
64751                 ts.Debug.assert(!ts.isInJSFile(name));
64752                 var typeParameter = ts.getTypeParameterFromJsDoc(name.parent);
64753                 return typeParameter && typeParameter.symbol;
64754             }
64755             if (ts.isExpressionNode(name)) {
64756                 if (ts.nodeIsMissing(name)) {
64757                     return undefined;
64758                 }
64759                 if (name.kind === 78) {
64760                     if (ts.isJSXTagName(name) && isJsxIntrinsicIdentifier(name)) {
64761                         var symbol = getIntrinsicTagSymbol(name.parent);
64762                         return symbol === unknownSymbol ? undefined : symbol;
64763                     }
64764                     return resolveEntityName(name, 111551, false, true);
64765                 }
64766                 else if (name.kind === 201 || name.kind === 157) {
64767                     var links = getNodeLinks(name);
64768                     if (links.resolvedSymbol) {
64769                         return links.resolvedSymbol;
64770                     }
64771                     if (name.kind === 201) {
64772                         checkPropertyAccessExpression(name);
64773                     }
64774                     else {
64775                         checkQualifiedName(name);
64776                     }
64777                     return links.resolvedSymbol;
64778                 }
64779             }
64780             else if (isTypeReferenceIdentifier(name)) {
64781                 var meaning = name.parent.kind === 173 ? 788968 : 1920;
64782                 return resolveEntityName(name, meaning, false, true);
64783             }
64784             else if (isJSDocEntryNameReference(name)) {
64785                 var meaning = 788968 | 1920 | 111551;
64786                 return resolveEntityName(name, meaning, false, true, ts.getHostSignatureFromJSDoc(name));
64787             }
64788             if (name.parent.kind === 172) {
64789                 return resolveEntityName(name, 1);
64790             }
64791             return undefined;
64792         }
64793         function getSymbolAtLocation(node, ignoreErrors) {
64794             if (node.kind === 297) {
64795                 return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined;
64796             }
64797             var parent = node.parent;
64798             var grandParent = parent.parent;
64799             if (node.flags & 16777216) {
64800                 return undefined;
64801             }
64802             if (isDeclarationNameOrImportPropertyName(node)) {
64803                 var parentSymbol = getSymbolOfNode(parent);
64804                 return ts.isImportOrExportSpecifier(node.parent) && node.parent.propertyName === node
64805                     ? getImmediateAliasedSymbol(parentSymbol)
64806                     : parentSymbol;
64807             }
64808             else if (ts.isLiteralComputedPropertyDeclarationName(node)) {
64809                 return getSymbolOfNode(parent.parent);
64810             }
64811             if (node.kind === 78) {
64812                 if (isInRightSideOfImportOrExportAssignment(node)) {
64813                     return getSymbolOfNameOrPropertyAccessExpression(node);
64814                 }
64815                 else if (parent.kind === 198 &&
64816                     grandParent.kind === 196 &&
64817                     node === parent.propertyName) {
64818                     var typeOfPattern = getTypeOfNode(grandParent);
64819                     var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText);
64820                     if (propertyDeclaration) {
64821                         return propertyDeclaration;
64822                     }
64823                 }
64824             }
64825             switch (node.kind) {
64826                 case 78:
64827                 case 79:
64828                 case 201:
64829                 case 157:
64830                     return getSymbolOfNameOrPropertyAccessExpression(node);
64831                 case 107:
64832                     var container = ts.getThisContainer(node, false);
64833                     if (ts.isFunctionLike(container)) {
64834                         var sig = getSignatureFromDeclaration(container);
64835                         if (sig.thisParameter) {
64836                             return sig.thisParameter;
64837                         }
64838                     }
64839                     if (ts.isInExpressionContext(node)) {
64840                         return checkExpression(node).symbol;
64841                     }
64842                 case 187:
64843                     return getTypeFromThisTypeNode(node).symbol;
64844                 case 105:
64845                     return checkExpression(node).symbol;
64846                 case 132:
64847                     var constructorDeclaration = node.parent;
64848                     if (constructorDeclaration && constructorDeclaration.kind === 166) {
64849                         return constructorDeclaration.parent.symbol;
64850                     }
64851                     return undefined;
64852                 case 10:
64853                 case 14:
64854                     if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) ||
64855                         ((node.parent.kind === 261 || node.parent.kind === 267) && node.parent.moduleSpecifier === node) ||
64856                         ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, false)) || ts.isImportCall(node.parent)) ||
64857                         (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) {
64858                         return resolveExternalModuleName(node, node, ignoreErrors);
64859                     }
64860                     if (ts.isCallExpression(parent) && ts.isBindableObjectDefinePropertyCall(parent) && parent.arguments[1] === node) {
64861                         return getSymbolOfNode(parent);
64862                     }
64863                 case 8:
64864                     var objectType = ts.isElementAccessExpression(parent)
64865                         ? parent.argumentExpression === node ? getTypeOfExpression(parent.expression) : undefined
64866                         : ts.isLiteralTypeNode(parent) && ts.isIndexedAccessTypeNode(grandParent)
64867                             ? getTypeFromTypeNode(grandParent.objectType)
64868                             : undefined;
64869                     return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text));
64870                 case 87:
64871                 case 97:
64872                 case 38:
64873                 case 83:
64874                     return getSymbolOfNode(node.parent);
64875                 case 195:
64876                     return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined;
64877                 case 92:
64878                     return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined;
64879                 default:
64880                     return undefined;
64881             }
64882         }
64883         function getShorthandAssignmentValueSymbol(location) {
64884             if (location && location.kind === 289) {
64885                 return resolveEntityName(location.name, 111551 | 2097152);
64886             }
64887             return undefined;
64888         }
64889         function getExportSpecifierLocalTargetSymbol(node) {
64890             if (ts.isExportSpecifier(node)) {
64891                 return node.parent.parent.moduleSpecifier ?
64892                     getExternalModuleMember(node.parent.parent, node) :
64893                     resolveEntityName(node.propertyName || node.name, 111551 | 788968 | 1920 | 2097152);
64894             }
64895             else {
64896                 return resolveEntityName(node, 111551 | 788968 | 1920 | 2097152);
64897             }
64898         }
64899         function getTypeOfNode(node) {
64900             if (ts.isSourceFile(node) && !ts.isExternalModule(node)) {
64901                 return errorType;
64902             }
64903             if (node.flags & 16777216) {
64904                 return errorType;
64905             }
64906             var classDecl = ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node);
64907             var classType = classDecl && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(classDecl.class));
64908             if (ts.isPartOfTypeNode(node)) {
64909                 var typeFromTypeNode = getTypeFromTypeNode(node);
64910                 return classType ? getTypeWithThisArgument(typeFromTypeNode, classType.thisType) : typeFromTypeNode;
64911             }
64912             if (ts.isExpressionNode(node)) {
64913                 return getRegularTypeOfExpression(node);
64914             }
64915             if (classType && !classDecl.isImplements) {
64916                 var baseType = ts.firstOrUndefined(getBaseTypes(classType));
64917                 return baseType ? getTypeWithThisArgument(baseType, classType.thisType) : errorType;
64918             }
64919             if (isTypeDeclaration(node)) {
64920                 var symbol = getSymbolOfNode(node);
64921                 return getDeclaredTypeOfSymbol(symbol);
64922             }
64923             if (isTypeDeclarationName(node)) {
64924                 var symbol = getSymbolAtLocation(node);
64925                 return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType;
64926             }
64927             if (ts.isDeclaration(node)) {
64928                 var symbol = getSymbolOfNode(node);
64929                 return getTypeOfSymbol(symbol);
64930             }
64931             if (isDeclarationNameOrImportPropertyName(node)) {
64932                 var symbol = getSymbolAtLocation(node);
64933                 if (symbol) {
64934                     return getTypeOfSymbol(symbol);
64935                 }
64936                 return errorType;
64937             }
64938             if (ts.isBindingPattern(node)) {
64939                 return getTypeForVariableLikeDeclaration(node.parent, true) || errorType;
64940             }
64941             if (isInRightSideOfImportOrExportAssignment(node)) {
64942                 var symbol = getSymbolAtLocation(node);
64943                 if (symbol) {
64944                     var declaredType = getDeclaredTypeOfSymbol(symbol);
64945                     return declaredType !== errorType ? declaredType : getTypeOfSymbol(symbol);
64946                 }
64947             }
64948             return errorType;
64949         }
64950         function getTypeOfAssignmentPattern(expr) {
64951             ts.Debug.assert(expr.kind === 200 || expr.kind === 199);
64952             if (expr.parent.kind === 239) {
64953                 var iteratedType = checkRightHandSideOfForOf(expr.parent);
64954                 return checkDestructuringAssignment(expr, iteratedType || errorType);
64955             }
64956             if (expr.parent.kind === 216) {
64957                 var iteratedType = getTypeOfExpression(expr.parent.right);
64958                 return checkDestructuringAssignment(expr, iteratedType || errorType);
64959             }
64960             if (expr.parent.kind === 288) {
64961                 var node_2 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
64962                 var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_2) || errorType;
64963                 var propertyIndex = ts.indexOfNode(node_2.properties, expr.parent);
64964                 return checkObjectLiteralDestructuringPropertyAssignment(node_2, typeOfParentObjectLiteral, propertyIndex);
64965             }
64966             var node = ts.cast(expr.parent, ts.isArrayLiteralExpression);
64967             var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType;
64968             var elementType = checkIteratedTypeOrElementType(65, typeOfArrayLiteral, undefinedType, expr.parent) || errorType;
64969             return checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, node.elements.indexOf(expr), elementType);
64970         }
64971         function getPropertySymbolOfDestructuringAssignment(location) {
64972             var typeOfObjectLiteral = getTypeOfAssignmentPattern(ts.cast(location.parent.parent, ts.isAssignmentPattern));
64973             return typeOfObjectLiteral && getPropertyOfType(typeOfObjectLiteral, location.escapedText);
64974         }
64975         function getRegularTypeOfExpression(expr) {
64976             if (ts.isRightSideOfQualifiedNameOrPropertyAccess(expr)) {
64977                 expr = expr.parent;
64978             }
64979             return getRegularTypeOfLiteralType(getTypeOfExpression(expr));
64980         }
64981         function getParentTypeOfClassElement(node) {
64982             var classSymbol = getSymbolOfNode(node.parent);
64983             return ts.hasSyntacticModifier(node, 32)
64984                 ? getTypeOfSymbol(classSymbol)
64985                 : getDeclaredTypeOfSymbol(classSymbol);
64986         }
64987         function getClassElementPropertyKeyType(element) {
64988             var name = element.name;
64989             switch (name.kind) {
64990                 case 78:
64991                     return getLiteralType(ts.idText(name));
64992                 case 8:
64993                 case 10:
64994                     return getLiteralType(name.text);
64995                 case 158:
64996                     var nameType = checkComputedPropertyName(name);
64997                     return isTypeAssignableToKind(nameType, 12288) ? nameType : stringType;
64998                 default:
64999                     return ts.Debug.fail("Unsupported property name.");
65000             }
65001         }
65002         function getAugmentedPropertiesOfType(type) {
65003             type = getApparentType(type);
65004             var propsByName = ts.createSymbolTable(getPropertiesOfType(type));
65005             var functionType = getSignaturesOfType(type, 0).length ? globalCallableFunctionType :
65006                 getSignaturesOfType(type, 1).length ? globalNewableFunctionType :
65007                     undefined;
65008             if (functionType) {
65009                 ts.forEach(getPropertiesOfType(functionType), function (p) {
65010                     if (!propsByName.has(p.escapedName)) {
65011                         propsByName.set(p.escapedName, p);
65012                     }
65013                 });
65014             }
65015             return getNamedMembers(propsByName);
65016         }
65017         function typeHasCallOrConstructSignatures(type) {
65018             return ts.typeHasCallOrConstructSignatures(type, checker);
65019         }
65020         function getRootSymbols(symbol) {
65021             var roots = getImmediateRootSymbols(symbol);
65022             return roots ? ts.flatMap(roots, getRootSymbols) : [symbol];
65023         }
65024         function getImmediateRootSymbols(symbol) {
65025             if (ts.getCheckFlags(symbol) & 6) {
65026                 return ts.mapDefined(getSymbolLinks(symbol).containingType.types, function (type) { return getPropertyOfType(type, symbol.escapedName); });
65027             }
65028             else if (symbol.flags & 33554432) {
65029                 var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin;
65030                 return leftSpread ? [leftSpread, rightSpread]
65031                     : syntheticOrigin ? [syntheticOrigin]
65032                         : ts.singleElementArray(tryGetAliasTarget(symbol));
65033             }
65034             return undefined;
65035         }
65036         function tryGetAliasTarget(symbol) {
65037             var target;
65038             var next = symbol;
65039             while (next = getSymbolLinks(next).target) {
65040                 target = next;
65041             }
65042             return target;
65043         }
65044         function isArgumentsLocalBinding(nodeIn) {
65045             if (ts.isGeneratedIdentifier(nodeIn))
65046                 return false;
65047             var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
65048             if (!node)
65049                 return false;
65050             var parent = node.parent;
65051             if (!parent)
65052                 return false;
65053             var isPropertyName = ((ts.isPropertyAccessExpression(parent)
65054                 || ts.isPropertyAssignment(parent))
65055                 && parent.name === node);
65056             return !isPropertyName && getReferencedValueSymbol(node) === argumentsSymbol;
65057         }
65058         function moduleExportsSomeValue(moduleReferenceExpression) {
65059             var moduleSymbol = resolveExternalModuleName(moduleReferenceExpression.parent, moduleReferenceExpression);
65060             if (!moduleSymbol || ts.isShorthandAmbientModuleSymbol(moduleSymbol)) {
65061                 return true;
65062             }
65063             var hasExportAssignment = hasExportAssignmentSymbol(moduleSymbol);
65064             moduleSymbol = resolveExternalModuleSymbol(moduleSymbol);
65065             var symbolLinks = getSymbolLinks(moduleSymbol);
65066             if (symbolLinks.exportsSomeValue === undefined) {
65067                 symbolLinks.exportsSomeValue = hasExportAssignment
65068                     ? !!(moduleSymbol.flags & 111551)
65069                     : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue);
65070             }
65071             return symbolLinks.exportsSomeValue;
65072             function isValue(s) {
65073                 s = resolveSymbol(s);
65074                 return s && !!(s.flags & 111551);
65075             }
65076         }
65077         function isNameOfModuleOrEnumDeclaration(node) {
65078             return ts.isModuleOrEnumDeclaration(node.parent) && node === node.parent.name;
65079         }
65080         function getReferencedExportContainer(nodeIn, prefixLocals) {
65081             var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
65082             if (node) {
65083                 var symbol = getReferencedValueSymbol(node, isNameOfModuleOrEnumDeclaration(node));
65084                 if (symbol) {
65085                     if (symbol.flags & 1048576) {
65086                         var exportSymbol = getMergedSymbol(symbol.exportSymbol);
65087                         if (!prefixLocals && exportSymbol.flags & 944 && !(exportSymbol.flags & 3)) {
65088                             return undefined;
65089                         }
65090                         symbol = exportSymbol;
65091                     }
65092                     var parentSymbol_1 = getParentOfSymbol(symbol);
65093                     if (parentSymbol_1) {
65094                         if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 297) {
65095                             var symbolFile = parentSymbol_1.valueDeclaration;
65096                             var referenceFile = ts.getSourceFileOfNode(node);
65097                             var symbolIsUmdExport = symbolFile !== referenceFile;
65098                             return symbolIsUmdExport ? undefined : symbolFile;
65099                         }
65100                         return ts.findAncestor(node.parent, function (n) { return ts.isModuleOrEnumDeclaration(n) && getSymbolOfNode(n) === parentSymbol_1; });
65101                     }
65102                 }
65103             }
65104         }
65105         function getReferencedImportDeclaration(nodeIn) {
65106             if (nodeIn.generatedImportReference) {
65107                 return nodeIn.generatedImportReference;
65108             }
65109             var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
65110             if (node) {
65111                 var symbol = getReferencedValueSymbol(node);
65112                 if (isNonLocalAlias(symbol, 111551) && !getTypeOnlyAliasDeclaration(symbol)) {
65113                     return getDeclarationOfAliasSymbol(symbol);
65114                 }
65115             }
65116             return undefined;
65117         }
65118         function isSymbolOfDestructuredElementOfCatchBinding(symbol) {
65119             return ts.isBindingElement(symbol.valueDeclaration)
65120                 && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 287;
65121         }
65122         function isSymbolOfDeclarationWithCollidingName(symbol) {
65123             if (symbol.flags & 418 && !ts.isSourceFile(symbol.valueDeclaration)) {
65124                 var links = getSymbolLinks(symbol);
65125                 if (links.isDeclarationWithCollidingName === undefined) {
65126                     var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration);
65127                     if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) {
65128                         var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration);
65129                         if (resolveName(container.parent, symbol.escapedName, 111551, undefined, undefined, false)) {
65130                             links.isDeclarationWithCollidingName = true;
65131                         }
65132                         else if (nodeLinks_1.flags & 262144) {
65133                             var isDeclaredInLoop = nodeLinks_1.flags & 524288;
65134                             var inLoopInitializer = ts.isIterationStatement(container, false);
65135                             var inLoopBodyBlock = container.kind === 230 && ts.isIterationStatement(container.parent, false);
65136                             links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock));
65137                         }
65138                         else {
65139                             links.isDeclarationWithCollidingName = false;
65140                         }
65141                     }
65142                 }
65143                 return links.isDeclarationWithCollidingName;
65144             }
65145             return false;
65146         }
65147         function getReferencedDeclarationWithCollidingName(nodeIn) {
65148             if (!ts.isGeneratedIdentifier(nodeIn)) {
65149                 var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
65150                 if (node) {
65151                     var symbol = getReferencedValueSymbol(node);
65152                     if (symbol && isSymbolOfDeclarationWithCollidingName(symbol)) {
65153                         return symbol.valueDeclaration;
65154                     }
65155                 }
65156             }
65157             return undefined;
65158         }
65159         function isDeclarationWithCollidingName(nodeIn) {
65160             var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration);
65161             if (node) {
65162                 var symbol = getSymbolOfNode(node);
65163                 if (symbol) {
65164                     return isSymbolOfDeclarationWithCollidingName(symbol);
65165                 }
65166             }
65167             return false;
65168         }
65169         function isValueAliasDeclaration(node) {
65170             switch (node.kind) {
65171                 case 260:
65172                     return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol);
65173                 case 262:
65174                 case 263:
65175                 case 265:
65176                 case 270:
65177                     var symbol = getSymbolOfNode(node) || unknownSymbol;
65178                     return isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol);
65179                 case 267:
65180                     var exportClause = node.exportClause;
65181                     return !!exportClause && (ts.isNamespaceExport(exportClause) ||
65182                         ts.some(exportClause.elements, isValueAliasDeclaration));
65183                 case 266:
65184                     return node.expression && node.expression.kind === 78 ?
65185                         isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) :
65186                         true;
65187             }
65188             return false;
65189         }
65190         function isTopLevelValueImportEqualsWithEntityName(nodeIn) {
65191             var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration);
65192             if (node === undefined || node.parent.kind !== 297 || !ts.isInternalModuleImportEqualsDeclaration(node)) {
65193                 return false;
65194             }
65195             var isValue = isAliasResolvedToValue(getSymbolOfNode(node));
65196             return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference);
65197         }
65198         function isAliasResolvedToValue(symbol) {
65199             var target = resolveAlias(symbol);
65200             if (target === unknownSymbol) {
65201                 return true;
65202             }
65203             return !!(target.flags & 111551) &&
65204                 (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target));
65205         }
65206         function isConstEnumOrConstEnumOnlyModule(s) {
65207             return isConstEnumSymbol(s) || !!s.constEnumOnlyModule;
65208         }
65209         function isReferencedAliasDeclaration(node, checkChildren) {
65210             if (isAliasSymbolDeclaration(node)) {
65211                 var symbol = getSymbolOfNode(node);
65212                 if (symbol && getSymbolLinks(symbol).referenced) {
65213                     return true;
65214                 }
65215                 var target = getSymbolLinks(symbol).target;
65216                 if (target && ts.getEffectiveModifierFlags(node) & 1 &&
65217                     target.flags & 111551 &&
65218                     (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) {
65219                     return true;
65220                 }
65221             }
65222             if (checkChildren) {
65223                 return !!ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); });
65224             }
65225             return false;
65226         }
65227         function isImplementationOfOverload(node) {
65228             if (ts.nodeIsPresent(node.body)) {
65229                 if (ts.isGetAccessor(node) || ts.isSetAccessor(node))
65230                     return false;
65231                 var symbol = getSymbolOfNode(node);
65232                 var signaturesOfSymbol = getSignaturesOfSymbol(symbol);
65233                 return signaturesOfSymbol.length > 1 ||
65234                     (signaturesOfSymbol.length === 1 && signaturesOfSymbol[0].declaration !== node);
65235             }
65236             return false;
65237         }
65238         function isRequiredInitializedParameter(parameter) {
65239             return !!strictNullChecks &&
65240                 !isOptionalParameter(parameter) &&
65241                 !ts.isJSDocParameterTag(parameter) &&
65242                 !!parameter.initializer &&
65243                 !ts.hasSyntacticModifier(parameter, 92);
65244         }
65245         function isOptionalUninitializedParameterProperty(parameter) {
65246             return strictNullChecks &&
65247                 isOptionalParameter(parameter) &&
65248                 !parameter.initializer &&
65249                 ts.hasSyntacticModifier(parameter, 92);
65250         }
65251         function isOptionalUninitializedParameter(parameter) {
65252             return !!strictNullChecks &&
65253                 isOptionalParameter(parameter) &&
65254                 !parameter.initializer;
65255         }
65256         function isExpandoFunctionDeclaration(node) {
65257             var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration);
65258             if (!declaration) {
65259                 return false;
65260             }
65261             var symbol = getSymbolOfNode(declaration);
65262             if (!symbol || !(symbol.flags & 16)) {
65263                 return false;
65264             }
65265             return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); });
65266         }
65267         function getPropertiesOfContainerFunction(node) {
65268             var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration);
65269             if (!declaration) {
65270                 return ts.emptyArray;
65271             }
65272             var symbol = getSymbolOfNode(declaration);
65273             return symbol && getPropertiesOfType(getTypeOfSymbol(symbol)) || ts.emptyArray;
65274         }
65275         function getNodeCheckFlags(node) {
65276             return getNodeLinks(node).flags || 0;
65277         }
65278         function getEnumMemberValue(node) {
65279             computeEnumMemberValues(node.parent);
65280             return getNodeLinks(node).enumMemberValue;
65281         }
65282         function canHaveConstantValue(node) {
65283             switch (node.kind) {
65284                 case 291:
65285                 case 201:
65286                 case 202:
65287                     return true;
65288             }
65289             return false;
65290         }
65291         function getConstantValue(node) {
65292             if (node.kind === 291) {
65293                 return getEnumMemberValue(node);
65294             }
65295             var symbol = getNodeLinks(node).resolvedSymbol;
65296             if (symbol && (symbol.flags & 8)) {
65297                 var member = symbol.valueDeclaration;
65298                 if (ts.isEnumConst(member.parent)) {
65299                     return getEnumMemberValue(member);
65300                 }
65301             }
65302             return undefined;
65303         }
65304         function isFunctionType(type) {
65305             return !!(type.flags & 524288) && getSignaturesOfType(type, 0).length > 0;
65306         }
65307         function getTypeReferenceSerializationKind(typeNameIn, location) {
65308             var _a;
65309             var typeName = ts.getParseTreeNode(typeNameIn, ts.isEntityName);
65310             if (!typeName)
65311                 return ts.TypeReferenceSerializationKind.Unknown;
65312             if (location) {
65313                 location = ts.getParseTreeNode(location);
65314                 if (!location)
65315                     return ts.TypeReferenceSerializationKind.Unknown;
65316             }
65317             var valueSymbol = resolveEntityName(typeName, 111551, true, true, location);
65318             var isTypeOnly = ((_a = valueSymbol === null || valueSymbol === void 0 ? void 0 : valueSymbol.declarations) === null || _a === void 0 ? void 0 : _a.every(ts.isTypeOnlyImportOrExportDeclaration)) || false;
65319             var resolvedSymbol = valueSymbol && valueSymbol.flags & 2097152 ? resolveAlias(valueSymbol) : valueSymbol;
65320             var typeSymbol = resolveEntityName(typeName, 788968, true, false, location);
65321             if (resolvedSymbol && resolvedSymbol === typeSymbol) {
65322                 var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(false);
65323                 if (globalPromiseSymbol && resolvedSymbol === globalPromiseSymbol) {
65324                     return ts.TypeReferenceSerializationKind.Promise;
65325                 }
65326                 var constructorType = getTypeOfSymbol(resolvedSymbol);
65327                 if (constructorType && isConstructorType(constructorType)) {
65328                     return isTypeOnly ? ts.TypeReferenceSerializationKind.TypeWithCallSignature : ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue;
65329                 }
65330             }
65331             if (!typeSymbol) {
65332                 return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown;
65333             }
65334             var type = getDeclaredTypeOfSymbol(typeSymbol);
65335             if (type === errorType) {
65336                 return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown;
65337             }
65338             else if (type.flags & 3) {
65339                 return ts.TypeReferenceSerializationKind.ObjectType;
65340             }
65341             else if (isTypeAssignableToKind(type, 16384 | 98304 | 131072)) {
65342                 return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType;
65343             }
65344             else if (isTypeAssignableToKind(type, 528)) {
65345                 return ts.TypeReferenceSerializationKind.BooleanType;
65346             }
65347             else if (isTypeAssignableToKind(type, 296)) {
65348                 return ts.TypeReferenceSerializationKind.NumberLikeType;
65349             }
65350             else if (isTypeAssignableToKind(type, 2112)) {
65351                 return ts.TypeReferenceSerializationKind.BigIntLikeType;
65352             }
65353             else if (isTypeAssignableToKind(type, 402653316)) {
65354                 return ts.TypeReferenceSerializationKind.StringLikeType;
65355             }
65356             else if (isTupleType(type)) {
65357                 return ts.TypeReferenceSerializationKind.ArrayLikeType;
65358             }
65359             else if (isTypeAssignableToKind(type, 12288)) {
65360                 return ts.TypeReferenceSerializationKind.ESSymbolType;
65361             }
65362             else if (isFunctionType(type)) {
65363                 return ts.TypeReferenceSerializationKind.TypeWithCallSignature;
65364             }
65365             else if (isArrayType(type)) {
65366                 return ts.TypeReferenceSerializationKind.ArrayLikeType;
65367             }
65368             else {
65369                 return ts.TypeReferenceSerializationKind.ObjectType;
65370             }
65371         }
65372         function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) {
65373             var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor);
65374             if (!declaration) {
65375                 return ts.factory.createToken(128);
65376             }
65377             var symbol = getSymbolOfNode(declaration);
65378             var type = symbol && !(symbol.flags & (2048 | 131072))
65379                 ? getWidenedLiteralType(getTypeOfSymbol(symbol))
65380                 : errorType;
65381             if (type.flags & 8192 &&
65382                 type.symbol === symbol) {
65383                 flags |= 1048576;
65384             }
65385             if (addUndefined) {
65386                 type = getOptionalType(type);
65387             }
65388             return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024, tracker);
65389         }
65390         function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) {
65391             var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike);
65392             if (!signatureDeclaration) {
65393                 return ts.factory.createToken(128);
65394             }
65395             var signature = getSignatureFromDeclaration(signatureDeclaration);
65396             return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024, tracker);
65397         }
65398         function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) {
65399             var expr = ts.getParseTreeNode(exprIn, ts.isExpression);
65400             if (!expr) {
65401                 return ts.factory.createToken(128);
65402             }
65403             var type = getWidenedType(getRegularTypeOfExpression(expr));
65404             return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024, tracker);
65405         }
65406         function hasGlobalName(name) {
65407             return globals.has(ts.escapeLeadingUnderscores(name));
65408         }
65409         function getReferencedValueSymbol(reference, startInDeclarationContainer) {
65410             var resolvedSymbol = getNodeLinks(reference).resolvedSymbol;
65411             if (resolvedSymbol) {
65412                 return resolvedSymbol;
65413             }
65414             var location = reference;
65415             if (startInDeclarationContainer) {
65416                 var parent = reference.parent;
65417                 if (ts.isDeclaration(parent) && reference === parent.name) {
65418                     location = getDeclarationContainer(parent);
65419                 }
65420             }
65421             return resolveName(location, reference.escapedText, 111551 | 1048576 | 2097152, undefined, undefined, true);
65422         }
65423         function getReferencedValueDeclaration(referenceIn) {
65424             if (!ts.isGeneratedIdentifier(referenceIn)) {
65425                 var reference = ts.getParseTreeNode(referenceIn, ts.isIdentifier);
65426                 if (reference) {
65427                     var symbol = getReferencedValueSymbol(reference);
65428                     if (symbol) {
65429                         return getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration;
65430                     }
65431                 }
65432             }
65433             return undefined;
65434         }
65435         function isLiteralConstDeclaration(node) {
65436             if (ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) {
65437                 return isFreshLiteralType(getTypeOfSymbol(getSymbolOfNode(node)));
65438             }
65439             return false;
65440         }
65441         function literalTypeToNode(type, enclosing, tracker) {
65442             var enumResult = type.flags & 1024 ? nodeBuilder.symbolToExpression(type.symbol, 111551, enclosing, undefined, tracker)
65443                 : type === trueType ? ts.factory.createTrue() : type === falseType && ts.factory.createFalse();
65444             if (enumResult)
65445                 return enumResult;
65446             var literalValue = type.value;
65447             return typeof literalValue === "object" ? ts.factory.createBigIntLiteral(literalValue) :
65448                 typeof literalValue === "number" ? ts.factory.createNumericLiteral(literalValue) :
65449                     ts.factory.createStringLiteral(literalValue);
65450         }
65451         function createLiteralConstValue(node, tracker) {
65452             var type = getTypeOfSymbol(getSymbolOfNode(node));
65453             return literalTypeToNode(type, node, tracker);
65454         }
65455         function getJsxFactoryEntity(location) {
65456             return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity;
65457         }
65458         function getJsxFragmentFactoryEntity(location) {
65459             if (location) {
65460                 var file = ts.getSourceFileOfNode(location);
65461                 if (file) {
65462                     if (file.localJsxFragmentFactory) {
65463                         return file.localJsxFragmentFactory;
65464                     }
65465                     var jsxFragPragmas = file.pragmas.get("jsxfrag");
65466                     var jsxFragPragma = ts.isArray(jsxFragPragmas) ? jsxFragPragmas[0] : jsxFragPragmas;
65467                     if (jsxFragPragma) {
65468                         file.localJsxFragmentFactory = ts.parseIsolatedEntityName(jsxFragPragma.arguments.factory, languageVersion);
65469                         return file.localJsxFragmentFactory;
65470                     }
65471                 }
65472             }
65473             if (compilerOptions.jsxFragmentFactory) {
65474                 return ts.parseIsolatedEntityName(compilerOptions.jsxFragmentFactory, languageVersion);
65475             }
65476         }
65477         function createResolver() {
65478             var resolvedTypeReferenceDirectives = host.getResolvedTypeReferenceDirectives();
65479             var fileToDirective;
65480             if (resolvedTypeReferenceDirectives) {
65481                 fileToDirective = new ts.Map();
65482                 resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) {
65483                     if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
65484                         return;
65485                     }
65486                     var file = host.getSourceFile(resolvedDirective.resolvedFileName);
65487                     if (file) {
65488                         addReferencedFilesToTypeDirective(file, key);
65489                     }
65490                 });
65491             }
65492             return {
65493                 getReferencedExportContainer: getReferencedExportContainer,
65494                 getReferencedImportDeclaration: getReferencedImportDeclaration,
65495                 getReferencedDeclarationWithCollidingName: getReferencedDeclarationWithCollidingName,
65496                 isDeclarationWithCollidingName: isDeclarationWithCollidingName,
65497                 isValueAliasDeclaration: function (nodeIn) {
65498                     var node = ts.getParseTreeNode(nodeIn);
65499                     return node ? isValueAliasDeclaration(node) : true;
65500                 },
65501                 hasGlobalName: hasGlobalName,
65502                 isReferencedAliasDeclaration: function (nodeIn, checkChildren) {
65503                     var node = ts.getParseTreeNode(nodeIn);
65504                     return node ? isReferencedAliasDeclaration(node, checkChildren) : true;
65505                 },
65506                 getNodeCheckFlags: function (nodeIn) {
65507                     var node = ts.getParseTreeNode(nodeIn);
65508                     return node ? getNodeCheckFlags(node) : 0;
65509                 },
65510                 isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName,
65511                 isDeclarationVisible: isDeclarationVisible,
65512                 isImplementationOfOverload: isImplementationOfOverload,
65513                 isRequiredInitializedParameter: isRequiredInitializedParameter,
65514                 isOptionalUninitializedParameterProperty: isOptionalUninitializedParameterProperty,
65515                 isExpandoFunctionDeclaration: isExpandoFunctionDeclaration,
65516                 getPropertiesOfContainerFunction: getPropertiesOfContainerFunction,
65517                 createTypeOfDeclaration: createTypeOfDeclaration,
65518                 createReturnTypeOfSignatureDeclaration: createReturnTypeOfSignatureDeclaration,
65519                 createTypeOfExpression: createTypeOfExpression,
65520                 createLiteralConstValue: createLiteralConstValue,
65521                 isSymbolAccessible: isSymbolAccessible,
65522                 isEntityNameVisible: isEntityNameVisible,
65523                 getConstantValue: function (nodeIn) {
65524                     var node = ts.getParseTreeNode(nodeIn, canHaveConstantValue);
65525                     return node ? getConstantValue(node) : undefined;
65526                 },
65527                 collectLinkedAliases: collectLinkedAliases,
65528                 getReferencedValueDeclaration: getReferencedValueDeclaration,
65529                 getTypeReferenceSerializationKind: getTypeReferenceSerializationKind,
65530                 isOptionalParameter: isOptionalParameter,
65531                 moduleExportsSomeValue: moduleExportsSomeValue,
65532                 isArgumentsLocalBinding: isArgumentsLocalBinding,
65533                 getExternalModuleFileFromDeclaration: getExternalModuleFileFromDeclaration,
65534                 getTypeReferenceDirectivesForEntityName: getTypeReferenceDirectivesForEntityName,
65535                 getTypeReferenceDirectivesForSymbol: getTypeReferenceDirectivesForSymbol,
65536                 isLiteralConstDeclaration: isLiteralConstDeclaration,
65537                 isLateBound: function (nodeIn) {
65538                     var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration);
65539                     var symbol = node && getSymbolOfNode(node);
65540                     return !!(symbol && ts.getCheckFlags(symbol) & 4096);
65541                 },
65542                 getJsxFactoryEntity: getJsxFactoryEntity,
65543                 getJsxFragmentFactoryEntity: getJsxFragmentFactoryEntity,
65544                 getAllAccessorDeclarations: function (accessor) {
65545                     accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration);
65546                     var otherKind = accessor.kind === 168 ? 167 : 168;
65547                     var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(accessor), otherKind);
65548                     var firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor;
65549                     var secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor;
65550                     var setAccessor = accessor.kind === 168 ? accessor : otherAccessor;
65551                     var getAccessor = accessor.kind === 167 ? accessor : otherAccessor;
65552                     return {
65553                         firstAccessor: firstAccessor,
65554                         secondAccessor: secondAccessor,
65555                         setAccessor: setAccessor,
65556                         getAccessor: getAccessor
65557                     };
65558                 },
65559                 getSymbolOfExternalModuleSpecifier: function (moduleName) { return resolveExternalModuleNameWorker(moduleName, moduleName, undefined); },
65560                 isBindingCapturedByNode: function (node, decl) {
65561                     var parseNode = ts.getParseTreeNode(node);
65562                     var parseDecl = ts.getParseTreeNode(decl);
65563                     return !!parseNode && !!parseDecl && (ts.isVariableDeclaration(parseDecl) || ts.isBindingElement(parseDecl)) && isBindingCapturedByNode(parseNode, parseDecl);
65564                 },
65565                 getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) {
65566                     var n = ts.getParseTreeNode(node);
65567                     ts.Debug.assert(n && n.kind === 297, "Non-sourcefile node passed into getDeclarationsForSourceFile");
65568                     var sym = getSymbolOfNode(node);
65569                     if (!sym) {
65570                         return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled);
65571                     }
65572                     return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled);
65573                 },
65574                 isImportRequiredByAugmentation: isImportRequiredByAugmentation,
65575             };
65576             function isImportRequiredByAugmentation(node) {
65577                 var file = ts.getSourceFileOfNode(node);
65578                 if (!file.symbol)
65579                     return false;
65580                 var importTarget = getExternalModuleFileFromDeclaration(node);
65581                 if (!importTarget)
65582                     return false;
65583                 if (importTarget === file)
65584                     return false;
65585                 var exports = getExportsOfModule(file.symbol);
65586                 for (var _i = 0, _a = ts.arrayFrom(exports.values()); _i < _a.length; _i++) {
65587                     var s = _a[_i];
65588                     if (s.mergeId) {
65589                         var merged = getMergedSymbol(s);
65590                         for (var _b = 0, _c = merged.declarations; _b < _c.length; _b++) {
65591                             var d = _c[_b];
65592                             var declFile = ts.getSourceFileOfNode(d);
65593                             if (declFile === importTarget) {
65594                                 return true;
65595                             }
65596                         }
65597                     }
65598                 }
65599                 return false;
65600             }
65601             function isInHeritageClause(node) {
65602                 return node.parent && node.parent.kind === 223 && node.parent.parent && node.parent.parent.kind === 286;
65603             }
65604             function getTypeReferenceDirectivesForEntityName(node) {
65605                 if (!fileToDirective) {
65606                     return undefined;
65607                 }
65608                 var meaning = 788968 | 1920;
65609                 if ((node.kind === 78 && isInTypeQuery(node)) || (node.kind === 201 && !isInHeritageClause(node))) {
65610                     meaning = 111551 | 1048576;
65611                 }
65612                 var symbol = resolveEntityName(node, meaning, true);
65613                 return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined;
65614             }
65615             function getTypeReferenceDirectivesForSymbol(symbol, meaning) {
65616                 if (!fileToDirective) {
65617                     return undefined;
65618                 }
65619                 if (!isSymbolFromTypeDeclarationFile(symbol)) {
65620                     return undefined;
65621                 }
65622                 var typeReferenceDirectives;
65623                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
65624                     var decl = _a[_i];
65625                     if (decl.symbol && decl.symbol.flags & meaning) {
65626                         var file = ts.getSourceFileOfNode(decl);
65627                         var typeReferenceDirective = fileToDirective.get(file.path);
65628                         if (typeReferenceDirective) {
65629                             (typeReferenceDirectives || (typeReferenceDirectives = [])).push(typeReferenceDirective);
65630                         }
65631                         else {
65632                             return undefined;
65633                         }
65634                     }
65635                 }
65636                 return typeReferenceDirectives;
65637             }
65638             function isSymbolFromTypeDeclarationFile(symbol) {
65639                 if (!symbol.declarations) {
65640                     return false;
65641                 }
65642                 var current = symbol;
65643                 while (true) {
65644                     var parent = getParentOfSymbol(current);
65645                     if (parent) {
65646                         current = parent;
65647                     }
65648                     else {
65649                         break;
65650                     }
65651                 }
65652                 if (current.valueDeclaration && current.valueDeclaration.kind === 297 && current.flags & 512) {
65653                     return false;
65654                 }
65655                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
65656                     var decl = _a[_i];
65657                     var file = ts.getSourceFileOfNode(decl);
65658                     if (fileToDirective.has(file.path)) {
65659                         return true;
65660                     }
65661                 }
65662                 return false;
65663             }
65664             function addReferencedFilesToTypeDirective(file, key) {
65665                 if (fileToDirective.has(file.path))
65666                     return;
65667                 fileToDirective.set(file.path, key);
65668                 for (var _i = 0, _a = file.referencedFiles; _i < _a.length; _i++) {
65669                     var fileName = _a[_i].fileName;
65670                     var resolvedFile = ts.resolveTripleslashReference(fileName, file.fileName);
65671                     var referencedFile = host.getSourceFile(resolvedFile);
65672                     if (referencedFile) {
65673                         addReferencedFilesToTypeDirective(referencedFile, key);
65674                     }
65675                 }
65676             }
65677         }
65678         function getExternalModuleFileFromDeclaration(declaration) {
65679             var specifier = declaration.kind === 256 ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration);
65680             var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, undefined);
65681             if (!moduleSymbol) {
65682                 return undefined;
65683             }
65684             return ts.getDeclarationOfKind(moduleSymbol, 297);
65685         }
65686         function initializeTypeChecker() {
65687             for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) {
65688                 var file = _a[_i];
65689                 ts.bindSourceFile(file, compilerOptions);
65690             }
65691             amalgamatedDuplicates = new ts.Map();
65692             var augmentations;
65693             for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) {
65694                 var file = _c[_b];
65695                 if (file.redirectInfo) {
65696                     continue;
65697                 }
65698                 if (!ts.isExternalOrCommonJsModule(file)) {
65699                     var fileGlobalThisSymbol = file.locals.get("globalThis");
65700                     if (fileGlobalThisSymbol) {
65701                         for (var _d = 0, _e = fileGlobalThisSymbol.declarations; _d < _e.length; _d++) {
65702                             var declaration = _e[_d];
65703                             diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0, "globalThis"));
65704                         }
65705                     }
65706                     mergeSymbolTable(globals, file.locals);
65707                 }
65708                 if (file.jsGlobalAugmentations) {
65709                     mergeSymbolTable(globals, file.jsGlobalAugmentations);
65710                 }
65711                 if (file.patternAmbientModules && file.patternAmbientModules.length) {
65712                     patternAmbientModules = ts.concatenate(patternAmbientModules, file.patternAmbientModules);
65713                 }
65714                 if (file.moduleAugmentations.length) {
65715                     (augmentations || (augmentations = [])).push(file.moduleAugmentations);
65716                 }
65717                 if (file.symbol && file.symbol.globalExports) {
65718                     var source = file.symbol.globalExports;
65719                     source.forEach(function (sourceSymbol, id) {
65720                         if (!globals.has(id)) {
65721                             globals.set(id, sourceSymbol);
65722                         }
65723                     });
65724                 }
65725             }
65726             if (augmentations) {
65727                 for (var _f = 0, augmentations_1 = augmentations; _f < augmentations_1.length; _f++) {
65728                     var list = augmentations_1[_f];
65729                     for (var _g = 0, list_1 = list; _g < list_1.length; _g++) {
65730                         var augmentation = list_1[_g];
65731                         if (!ts.isGlobalScopeAugmentation(augmentation.parent))
65732                             continue;
65733                         mergeModuleAugmentation(augmentation);
65734                     }
65735                 }
65736             }
65737             addToSymbolTable(globals, builtinGlobals, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0);
65738             getSymbolLinks(undefinedSymbol).type = undefinedWideningType;
65739             getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", 0, true);
65740             getSymbolLinks(unknownSymbol).type = errorType;
65741             getSymbolLinks(globalThisSymbol).type = createObjectType(16, globalThisSymbol);
65742             globalArrayType = getGlobalType("Array", 1, true);
65743             globalObjectType = getGlobalType("Object", 0, true);
65744             globalFunctionType = getGlobalType("Function", 0, true);
65745             globalCallableFunctionType = strictBindCallApply && getGlobalType("CallableFunction", 0, true) || globalFunctionType;
65746             globalNewableFunctionType = strictBindCallApply && getGlobalType("NewableFunction", 0, true) || globalFunctionType;
65747             globalStringType = getGlobalType("String", 0, true);
65748             globalNumberType = getGlobalType("Number", 0, true);
65749             globalBooleanType = getGlobalType("Boolean", 0, true);
65750             globalRegExpType = getGlobalType("RegExp", 0, true);
65751             anyArrayType = createArrayType(anyType);
65752             autoArrayType = createArrayType(autoType);
65753             if (autoArrayType === emptyObjectType) {
65754                 autoArrayType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
65755             }
65756             globalReadonlyArrayType = getGlobalTypeOrUndefined("ReadonlyArray", 1) || globalArrayType;
65757             anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType;
65758             globalThisType = getGlobalTypeOrUndefined("ThisType", 1);
65759             if (augmentations) {
65760                 for (var _h = 0, augmentations_2 = augmentations; _h < augmentations_2.length; _h++) {
65761                     var list = augmentations_2[_h];
65762                     for (var _j = 0, list_2 = list; _j < list_2.length; _j++) {
65763                         var augmentation = list_2[_j];
65764                         if (ts.isGlobalScopeAugmentation(augmentation.parent))
65765                             continue;
65766                         mergeModuleAugmentation(augmentation);
65767                     }
65768                 }
65769             }
65770             amalgamatedDuplicates.forEach(function (_a) {
65771                 var firstFile = _a.firstFile, secondFile = _a.secondFile, conflictingSymbols = _a.conflictingSymbols;
65772                 if (conflictingSymbols.size < 8) {
65773                     conflictingSymbols.forEach(function (_a, symbolName) {
65774                         var isBlockScoped = _a.isBlockScoped, firstFileLocations = _a.firstFileLocations, secondFileLocations = _a.secondFileLocations;
65775                         var message = isBlockScoped ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0;
65776                         for (var _i = 0, firstFileLocations_1 = firstFileLocations; _i < firstFileLocations_1.length; _i++) {
65777                             var node = firstFileLocations_1[_i];
65778                             addDuplicateDeclarationError(node, message, symbolName, secondFileLocations);
65779                         }
65780                         for (var _b = 0, secondFileLocations_1 = secondFileLocations; _b < secondFileLocations_1.length; _b++) {
65781                             var node = secondFileLocations_1[_b];
65782                             addDuplicateDeclarationError(node, message, symbolName, firstFileLocations);
65783                         }
65784                     });
65785                 }
65786                 else {
65787                     var list = ts.arrayFrom(conflictingSymbols.keys()).join(", ");
65788                     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)));
65789                     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)));
65790                 }
65791             });
65792             amalgamatedDuplicates = undefined;
65793         }
65794         function checkExternalEmitHelpers(location, helpers) {
65795             if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) {
65796                 var sourceFile = ts.getSourceFileOfNode(location);
65797                 if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 8388608)) {
65798                     var helpersModule = resolveHelpersModule(sourceFile, location);
65799                     if (helpersModule !== unknownSymbol) {
65800                         var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers;
65801                         for (var helper = 1; helper <= 4194304; helper <<= 1) {
65802                             if (uncheckedHelpers & helper) {
65803                                 var name = getHelperName(helper);
65804                                 var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551);
65805                                 if (!symbol) {
65806                                     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);
65807                                 }
65808                             }
65809                         }
65810                     }
65811                     requestedExternalEmitHelpers |= helpers;
65812                 }
65813             }
65814         }
65815         function getHelperName(helper) {
65816             switch (helper) {
65817                 case 1: return "__extends";
65818                 case 2: return "__assign";
65819                 case 4: return "__rest";
65820                 case 8: return "__decorate";
65821                 case 16: return "__metadata";
65822                 case 32: return "__param";
65823                 case 64: return "__awaiter";
65824                 case 128: return "__generator";
65825                 case 256: return "__values";
65826                 case 512: return "__read";
65827                 case 1024: return "__spread";
65828                 case 2048: return "__spreadArrays";
65829                 case 4096: return "__await";
65830                 case 8192: return "__asyncGenerator";
65831                 case 16384: return "__asyncDelegator";
65832                 case 32768: return "__asyncValues";
65833                 case 65536: return "__exportStar";
65834                 case 131072: return "__importStar";
65835                 case 262144: return "__importDefault";
65836                 case 524288: return "__makeTemplateObject";
65837                 case 1048576: return "__classPrivateFieldGet";
65838                 case 2097152: return "__classPrivateFieldSet";
65839                 case 4194304: return "__createBinding";
65840                 default: return ts.Debug.fail("Unrecognized helper");
65841             }
65842         }
65843         function resolveHelpersModule(node, errorNode) {
65844             if (!externalHelpersModule) {
65845                 externalHelpersModule = resolveExternalModule(node, ts.externalHelpersModuleNameText, ts.Diagnostics.This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found, errorNode) || unknownSymbol;
65846             }
65847             return externalHelpersModule;
65848         }
65849         function checkGrammarDecoratorsAndModifiers(node) {
65850             return checkGrammarDecorators(node) || checkGrammarModifiers(node);
65851         }
65852         function checkGrammarDecorators(node) {
65853             if (!node.decorators) {
65854                 return false;
65855             }
65856             if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) {
65857                 if (node.kind === 165 && !ts.nodeIsPresent(node.body)) {
65858                     return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload);
65859                 }
65860                 else {
65861                     return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here);
65862                 }
65863             }
65864             else if (node.kind === 167 || node.kind === 168) {
65865                 var accessors = ts.getAllAccessorDeclarations(node.parent.members, node);
65866                 if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) {
65867                     return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name);
65868                 }
65869             }
65870             return false;
65871         }
65872         function checkGrammarModifiers(node) {
65873             var quickResult = reportObviousModifierErrors(node);
65874             if (quickResult !== undefined) {
65875                 return quickResult;
65876             }
65877             var lastStatic, lastDeclare, lastAsync, lastReadonly;
65878             var flags = 0;
65879             for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
65880                 var modifier = _a[_i];
65881                 if (modifier.kind !== 142) {
65882                     if (node.kind === 162 || node.kind === 164) {
65883                         return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind));
65884                     }
65885                     if (node.kind === 171) {
65886                         return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind));
65887                     }
65888                 }
65889                 switch (modifier.kind) {
65890                     case 84:
65891                         if (node.kind !== 255) {
65892                             return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(84));
65893                         }
65894                         break;
65895                     case 122:
65896                     case 121:
65897                     case 120:
65898                         var text = visibilityToString(ts.modifierToFlag(modifier.kind));
65899                         if (flags & 28) {
65900                             return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen);
65901                         }
65902                         else if (flags & 32) {
65903                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static");
65904                         }
65905                         else if (flags & 64) {
65906                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "readonly");
65907                         }
65908                         else if (flags & 256) {
65909                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async");
65910                         }
65911                         else if (node.parent.kind === 257 || node.parent.kind === 297) {
65912                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text);
65913                         }
65914                         else if (flags & 128) {
65915                             if (modifier.kind === 120) {
65916                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract");
65917                             }
65918                             else {
65919                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract");
65920                             }
65921                         }
65922                         else if (ts.isPrivateIdentifierPropertyDeclaration(node)) {
65923                             return grammarErrorOnNode(modifier, ts.Diagnostics.An_accessibility_modifier_cannot_be_used_with_a_private_identifier);
65924                         }
65925                         flags |= ts.modifierToFlag(modifier.kind);
65926                         break;
65927                     case 123:
65928                         if (flags & 32) {
65929                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static");
65930                         }
65931                         else if (flags & 64) {
65932                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly");
65933                         }
65934                         else if (flags & 256) {
65935                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async");
65936                         }
65937                         else if (node.parent.kind === 257 || node.parent.kind === 297) {
65938                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static");
65939                         }
65940                         else if (node.kind === 160) {
65941                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static");
65942                         }
65943                         else if (flags & 128) {
65944                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract");
65945                         }
65946                         else if (ts.isPrivateIdentifierPropertyDeclaration(node)) {
65947                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "static");
65948                         }
65949                         flags |= 32;
65950                         lastStatic = modifier;
65951                         break;
65952                     case 142:
65953                         if (flags & 64) {
65954                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly");
65955                         }
65956                         else if (node.kind !== 163 && node.kind !== 162 && node.kind !== 171 && node.kind !== 160) {
65957                             return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature);
65958                         }
65959                         flags |= 64;
65960                         lastReadonly = modifier;
65961                         break;
65962                     case 92:
65963                         if (flags & 1) {
65964                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export");
65965                         }
65966                         else if (flags & 2) {
65967                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare");
65968                         }
65969                         else if (flags & 128) {
65970                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract");
65971                         }
65972                         else if (flags & 256) {
65973                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async");
65974                         }
65975                         else if (ts.isClassLike(node.parent)) {
65976                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "export");
65977                         }
65978                         else if (node.kind === 160) {
65979                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export");
65980                         }
65981                         flags |= 1;
65982                         break;
65983                     case 87:
65984                         var container = node.parent.kind === 297 ? node.parent : node.parent.parent;
65985                         if (container.kind === 256 && !ts.isAmbientModule(container)) {
65986                             return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module);
65987                         }
65988                         flags |= 512;
65989                         break;
65990                     case 133:
65991                         if (flags & 2) {
65992                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare");
65993                         }
65994                         else if (flags & 256) {
65995                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
65996                         }
65997                         else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) {
65998                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "declare");
65999                         }
66000                         else if (node.kind === 160) {
66001                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare");
66002                         }
66003                         else if ((node.parent.flags & 8388608) && node.parent.kind === 257) {
66004                             return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context);
66005                         }
66006                         else if (ts.isPrivateIdentifierPropertyDeclaration(node)) {
66007                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare");
66008                         }
66009                         flags |= 2;
66010                         lastDeclare = modifier;
66011                         break;
66012                     case 125:
66013                         if (flags & 128) {
66014                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract");
66015                         }
66016                         if (node.kind !== 252) {
66017                             if (node.kind !== 165 &&
66018                                 node.kind !== 163 &&
66019                                 node.kind !== 167 &&
66020                                 node.kind !== 168) {
66021                                 return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration);
66022                             }
66023                             if (!(node.parent.kind === 252 && ts.hasSyntacticModifier(node.parent, 128))) {
66024                                 return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class);
66025                             }
66026                             if (flags & 32) {
66027                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract");
66028                             }
66029                             if (flags & 8) {
66030                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract");
66031                             }
66032                             if (flags & 256 && lastAsync) {
66033                                 return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract");
66034                             }
66035                         }
66036                         if (ts.isNamedDeclaration(node) && node.name.kind === 79) {
66037                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract");
66038                         }
66039                         flags |= 128;
66040                         break;
66041                     case 129:
66042                         if (flags & 256) {
66043                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async");
66044                         }
66045                         else if (flags & 2 || node.parent.flags & 8388608) {
66046                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
66047                         }
66048                         else if (node.kind === 160) {
66049                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async");
66050                         }
66051                         if (flags & 128) {
66052                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract");
66053                         }
66054                         flags |= 256;
66055                         lastAsync = modifier;
66056                         break;
66057                 }
66058             }
66059             if (node.kind === 166) {
66060                 if (flags & 32) {
66061                     return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static");
66062                 }
66063                 if (flags & 128) {
66064                     return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract");
66065                 }
66066                 else if (flags & 256) {
66067                     return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async");
66068                 }
66069                 else if (flags & 64) {
66070                     return grammarErrorOnNode(lastReadonly, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "readonly");
66071                 }
66072                 return false;
66073             }
66074             else if ((node.kind === 261 || node.kind === 260) && flags & 2) {
66075                 return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare");
66076             }
66077             else if (node.kind === 160 && (flags & 92) && ts.isBindingPattern(node.name)) {
66078                 return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern);
66079             }
66080             else if (node.kind === 160 && (flags & 92) && node.dotDotDotToken) {
66081                 return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter);
66082             }
66083             if (flags & 256) {
66084                 return checkGrammarAsyncModifier(node, lastAsync);
66085             }
66086             return false;
66087         }
66088         function reportObviousModifierErrors(node) {
66089             return !node.modifiers
66090                 ? false
66091                 : shouldReportBadModifier(node)
66092                     ? grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here)
66093                     : undefined;
66094         }
66095         function shouldReportBadModifier(node) {
66096             switch (node.kind) {
66097                 case 167:
66098                 case 168:
66099                 case 166:
66100                 case 163:
66101                 case 162:
66102                 case 165:
66103                 case 164:
66104                 case 171:
66105                 case 256:
66106                 case 261:
66107                 case 260:
66108                 case 267:
66109                 case 266:
66110                 case 208:
66111                 case 209:
66112                 case 160:
66113                     return false;
66114                 default:
66115                     if (node.parent.kind === 257 || node.parent.kind === 297) {
66116                         return false;
66117                     }
66118                     switch (node.kind) {
66119                         case 251:
66120                             return nodeHasAnyModifiersExcept(node, 129);
66121                         case 252:
66122                             return nodeHasAnyModifiersExcept(node, 125);
66123                         case 253:
66124                         case 232:
66125                         case 254:
66126                             return true;
66127                         case 255:
66128                             return nodeHasAnyModifiersExcept(node, 84);
66129                         default:
66130                             ts.Debug.fail();
66131                             return false;
66132                     }
66133             }
66134         }
66135         function nodeHasAnyModifiersExcept(node, allowedModifier) {
66136             return node.modifiers.length > 1 || node.modifiers[0].kind !== allowedModifier;
66137         }
66138         function checkGrammarAsyncModifier(node, asyncModifier) {
66139             switch (node.kind) {
66140                 case 165:
66141                 case 251:
66142                 case 208:
66143                 case 209:
66144                     return false;
66145             }
66146             return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async");
66147         }
66148         function checkGrammarForDisallowedTrailingComma(list, diag) {
66149             if (diag === void 0) { diag = ts.Diagnostics.Trailing_comma_not_allowed; }
66150             if (list && list.hasTrailingComma) {
66151                 return grammarErrorAtPos(list[0], list.end - ",".length, ",".length, diag);
66152             }
66153             return false;
66154         }
66155         function checkGrammarTypeParameterList(typeParameters, file) {
66156             if (typeParameters && typeParameters.length === 0) {
66157                 var start = typeParameters.pos - "<".length;
66158                 var end = ts.skipTrivia(file.text, typeParameters.end) + ">".length;
66159                 return grammarErrorAtPos(file, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty);
66160             }
66161             return false;
66162         }
66163         function checkGrammarParameterList(parameters) {
66164             var seenOptionalParameter = false;
66165             var parameterCount = parameters.length;
66166             for (var i = 0; i < parameterCount; i++) {
66167                 var parameter = parameters[i];
66168                 if (parameter.dotDotDotToken) {
66169                     if (i !== (parameterCount - 1)) {
66170                         return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
66171                     }
66172                     if (!(parameter.flags & 8388608)) {
66173                         checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
66174                     }
66175                     if (parameter.questionToken) {
66176                         return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_rest_parameter_cannot_be_optional);
66177                     }
66178                     if (parameter.initializer) {
66179                         return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer);
66180                     }
66181                 }
66182                 else if (isOptionalParameter(parameter)) {
66183                     seenOptionalParameter = true;
66184                     if (parameter.questionToken && parameter.initializer) {
66185                         return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer);
66186                     }
66187                 }
66188                 else if (seenOptionalParameter && !parameter.initializer) {
66189                     return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter);
66190                 }
66191             }
66192         }
66193         function getNonSimpleParameters(parameters) {
66194             return ts.filter(parameters, function (parameter) { return !!parameter.initializer || ts.isBindingPattern(parameter.name) || ts.isRestParameter(parameter); });
66195         }
66196         function checkGrammarForUseStrictSimpleParameterList(node) {
66197             if (languageVersion >= 3) {
66198                 var useStrictDirective_1 = node.body && ts.isBlock(node.body) && ts.findUseStrictPrologue(node.body.statements);
66199                 if (useStrictDirective_1) {
66200                     var nonSimpleParameters = getNonSimpleParameters(node.parameters);
66201                     if (ts.length(nonSimpleParameters)) {
66202                         ts.forEach(nonSimpleParameters, function (parameter) {
66203                             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));
66204                         });
66205                         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)); });
66206                         ts.addRelatedInfo.apply(void 0, __spreadArrays([error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)], diagnostics_2));
66207                         return true;
66208                     }
66209                 }
66210             }
66211             return false;
66212         }
66213         function checkGrammarFunctionLikeDeclaration(node) {
66214             var file = ts.getSourceFileOfNode(node);
66215             return checkGrammarDecoratorsAndModifiers(node) ||
66216                 checkGrammarTypeParameterList(node.typeParameters, file) ||
66217                 checkGrammarParameterList(node.parameters) ||
66218                 checkGrammarArrowFunction(node, file) ||
66219                 (ts.isFunctionLikeDeclaration(node) && checkGrammarForUseStrictSimpleParameterList(node));
66220         }
66221         function checkGrammarClassLikeDeclaration(node) {
66222             var file = ts.getSourceFileOfNode(node);
66223             return checkGrammarClassDeclarationHeritageClauses(node) ||
66224                 checkGrammarTypeParameterList(node.typeParameters, file);
66225         }
66226         function checkGrammarArrowFunction(node, file) {
66227             if (!ts.isArrowFunction(node)) {
66228                 return false;
66229             }
66230             var equalsGreaterThanToken = node.equalsGreaterThanToken;
66231             var startLine = ts.getLineAndCharacterOfPosition(file, equalsGreaterThanToken.pos).line;
66232             var endLine = ts.getLineAndCharacterOfPosition(file, equalsGreaterThanToken.end).line;
66233             return startLine !== endLine && grammarErrorOnNode(equalsGreaterThanToken, ts.Diagnostics.Line_terminator_not_permitted_before_arrow);
66234         }
66235         function checkGrammarIndexSignatureParameters(node) {
66236             var parameter = node.parameters[0];
66237             if (node.parameters.length !== 1) {
66238                 if (parameter) {
66239                     return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter);
66240                 }
66241                 else {
66242                     return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter);
66243                 }
66244             }
66245             checkGrammarForDisallowedTrailingComma(node.parameters, ts.Diagnostics.An_index_signature_cannot_have_a_trailing_comma);
66246             if (parameter.dotDotDotToken) {
66247                 return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter);
66248             }
66249             if (ts.hasEffectiveModifiers(parameter)) {
66250                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier);
66251             }
66252             if (parameter.questionToken) {
66253                 return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark);
66254             }
66255             if (parameter.initializer) {
66256                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_initializer);
66257             }
66258             if (!parameter.type) {
66259                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation);
66260             }
66261             if (parameter.type.kind !== 147 && parameter.type.kind !== 144) {
66262                 var type = getTypeFromTypeNode(parameter.type);
66263                 if (type.flags & 4 || type.flags & 8) {
66264                     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));
66265                 }
66266                 if (type.flags & 1048576 && allTypesAssignableToKind(type, 384, true)) {
66267                     return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead);
66268                 }
66269                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_either_string_or_number);
66270             }
66271             if (!node.type) {
66272                 return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation);
66273             }
66274             return false;
66275         }
66276         function checkGrammarIndexSignature(node) {
66277             return checkGrammarDecoratorsAndModifiers(node) || checkGrammarIndexSignatureParameters(node);
66278         }
66279         function checkGrammarForAtLeastOneTypeArgument(node, typeArguments) {
66280             if (typeArguments && typeArguments.length === 0) {
66281                 var sourceFile = ts.getSourceFileOfNode(node);
66282                 var start = typeArguments.pos - "<".length;
66283                 var end = ts.skipTrivia(sourceFile.text, typeArguments.end) + ">".length;
66284                 return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty);
66285             }
66286             return false;
66287         }
66288         function checkGrammarTypeArguments(node, typeArguments) {
66289             return checkGrammarForDisallowedTrailingComma(typeArguments) ||
66290                 checkGrammarForAtLeastOneTypeArgument(node, typeArguments);
66291         }
66292         function checkGrammarTaggedTemplateChain(node) {
66293             if (node.questionDotToken || node.flags & 32) {
66294                 return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain);
66295             }
66296             return false;
66297         }
66298         function checkGrammarForOmittedArgument(args) {
66299             if (args) {
66300                 for (var _i = 0, args_4 = args; _i < args_4.length; _i++) {
66301                     var arg = args_4[_i];
66302                     if (arg.kind === 222) {
66303                         return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected);
66304                     }
66305                 }
66306             }
66307             return false;
66308         }
66309         function checkGrammarArguments(args) {
66310             return checkGrammarForOmittedArgument(args);
66311         }
66312         function checkGrammarHeritageClause(node) {
66313             var types = node.types;
66314             if (checkGrammarForDisallowedTrailingComma(types)) {
66315                 return true;
66316             }
66317             if (types && types.length === 0) {
66318                 var listType = ts.tokenToString(node.token);
66319                 return grammarErrorAtPos(node, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType);
66320             }
66321             return ts.some(types, checkGrammarExpressionWithTypeArguments);
66322         }
66323         function checkGrammarExpressionWithTypeArguments(node) {
66324             return checkGrammarTypeArguments(node, node.typeArguments);
66325         }
66326         function checkGrammarClassDeclarationHeritageClauses(node) {
66327             var seenExtendsClause = false;
66328             var seenImplementsClause = false;
66329             if (!checkGrammarDecoratorsAndModifiers(node) && node.heritageClauses) {
66330                 for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) {
66331                     var heritageClause = _a[_i];
66332                     if (heritageClause.token === 93) {
66333                         if (seenExtendsClause) {
66334                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen);
66335                         }
66336                         if (seenImplementsClause) {
66337                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_must_precede_implements_clause);
66338                         }
66339                         if (heritageClause.types.length > 1) {
66340                             return grammarErrorOnFirstToken(heritageClause.types[1], ts.Diagnostics.Classes_can_only_extend_a_single_class);
66341                         }
66342                         seenExtendsClause = true;
66343                     }
66344                     else {
66345                         ts.Debug.assert(heritageClause.token === 116);
66346                         if (seenImplementsClause) {
66347                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen);
66348                         }
66349                         seenImplementsClause = true;
66350                     }
66351                     checkGrammarHeritageClause(heritageClause);
66352                 }
66353             }
66354         }
66355         function checkGrammarInterfaceDeclaration(node) {
66356             var seenExtendsClause = false;
66357             if (node.heritageClauses) {
66358                 for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) {
66359                     var heritageClause = _a[_i];
66360                     if (heritageClause.token === 93) {
66361                         if (seenExtendsClause) {
66362                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen);
66363                         }
66364                         seenExtendsClause = true;
66365                     }
66366                     else {
66367                         ts.Debug.assert(heritageClause.token === 116);
66368                         return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause);
66369                     }
66370                     checkGrammarHeritageClause(heritageClause);
66371                 }
66372             }
66373             return false;
66374         }
66375         function checkGrammarComputedPropertyName(node) {
66376             if (node.kind !== 158) {
66377                 return false;
66378             }
66379             var computedPropertyName = node;
66380             if (computedPropertyName.expression.kind === 216 && computedPropertyName.expression.operatorToken.kind === 27) {
66381                 return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name);
66382             }
66383             return false;
66384         }
66385         function checkGrammarForGenerator(node) {
66386             if (node.asteriskToken) {
66387                 ts.Debug.assert(node.kind === 251 ||
66388                     node.kind === 208 ||
66389                     node.kind === 165);
66390                 if (node.flags & 8388608) {
66391                     return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context);
66392                 }
66393                 if (!node.body) {
66394                     return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator);
66395                 }
66396             }
66397         }
66398         function checkGrammarForInvalidQuestionMark(questionToken, message) {
66399             return !!questionToken && grammarErrorOnNode(questionToken, message);
66400         }
66401         function checkGrammarForInvalidExclamationToken(exclamationToken, message) {
66402             return !!exclamationToken && grammarErrorOnNode(exclamationToken, message);
66403         }
66404         function checkGrammarObjectLiteralExpression(node, inDestructuring) {
66405             var seen = new ts.Map();
66406             for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
66407                 var prop = _a[_i];
66408                 if (prop.kind === 290) {
66409                     if (inDestructuring) {
66410                         var expression = ts.skipParentheses(prop.expression);
66411                         if (ts.isArrayLiteralExpression(expression) || ts.isObjectLiteralExpression(expression)) {
66412                             return grammarErrorOnNode(prop.expression, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern);
66413                         }
66414                     }
66415                     continue;
66416                 }
66417                 var name = prop.name;
66418                 if (name.kind === 158) {
66419                     checkGrammarComputedPropertyName(name);
66420                 }
66421                 if (prop.kind === 289 && !inDestructuring && prop.objectAssignmentInitializer) {
66422                     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);
66423                 }
66424                 if (name.kind === 79) {
66425                     return grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
66426                 }
66427                 if (prop.modifiers) {
66428                     for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) {
66429                         var mod = _c[_b];
66430                         if (mod.kind !== 129 || prop.kind !== 165) {
66431                             grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod));
66432                         }
66433                     }
66434                 }
66435                 var currentKind = void 0;
66436                 switch (prop.kind) {
66437                     case 289:
66438                         checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context);
66439                     case 288:
66440                         checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional);
66441                         if (name.kind === 8) {
66442                             checkGrammarNumericLiteral(name);
66443                         }
66444                         currentKind = 4;
66445                         break;
66446                     case 165:
66447                         currentKind = 8;
66448                         break;
66449                     case 167:
66450                         currentKind = 1;
66451                         break;
66452                     case 168:
66453                         currentKind = 2;
66454                         break;
66455                     default:
66456                         throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind);
66457                 }
66458                 if (!inDestructuring) {
66459                     var effectiveName = ts.getPropertyNameForPropertyNameNode(name);
66460                     if (effectiveName === undefined) {
66461                         continue;
66462                     }
66463                     var existingKind = seen.get(effectiveName);
66464                     if (!existingKind) {
66465                         seen.set(effectiveName, currentKind);
66466                     }
66467                     else {
66468                         if ((currentKind & 12) && (existingKind & 12)) {
66469                             grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name));
66470                         }
66471                         else if ((currentKind & 3) && (existingKind & 3)) {
66472                             if (existingKind !== 3 && currentKind !== existingKind) {
66473                                 seen.set(effectiveName, currentKind | existingKind);
66474                             }
66475                             else {
66476                                 return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name);
66477                             }
66478                         }
66479                         else {
66480                             return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name);
66481                         }
66482                     }
66483                 }
66484             }
66485         }
66486         function checkGrammarJsxElement(node) {
66487             checkGrammarTypeArguments(node, node.typeArguments);
66488             var seen = new ts.Map();
66489             for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) {
66490                 var attr = _a[_i];
66491                 if (attr.kind === 282) {
66492                     continue;
66493                 }
66494                 var name = attr.name, initializer = attr.initializer;
66495                 if (!seen.get(name.escapedText)) {
66496                     seen.set(name.escapedText, true);
66497                 }
66498                 else {
66499                     return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name);
66500                 }
66501                 if (initializer && initializer.kind === 283 && !initializer.expression) {
66502                     return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression);
66503                 }
66504             }
66505         }
66506         function checkGrammarJsxExpression(node) {
66507             if (node.expression && ts.isCommaSequence(node.expression)) {
66508                 return grammarErrorOnNode(node.expression, ts.Diagnostics.JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array);
66509             }
66510         }
66511         function checkGrammarForInOrForOfStatement(forInOrOfStatement) {
66512             if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) {
66513                 return true;
66514             }
66515             if (forInOrOfStatement.kind === 239 && forInOrOfStatement.awaitModifier) {
66516                 if ((forInOrOfStatement.flags & 32768) === 0) {
66517                     var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement);
66518                     if (!hasParseDiagnostics(sourceFile)) {
66519                         var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator);
66520                         var func = ts.getContainingFunction(forInOrOfStatement);
66521                         if (func && func.kind !== 166) {
66522                             ts.Debug.assert((ts.getFunctionFlags(func) & 2) === 0, "Enclosing function should never be an async function.");
66523                             var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
66524                             ts.addRelatedInfo(diagnostic, relatedInfo);
66525                         }
66526                         diagnostics.add(diagnostic);
66527                         return true;
66528                     }
66529                     return false;
66530                 }
66531             }
66532             if (forInOrOfStatement.initializer.kind === 250) {
66533                 var variableList = forInOrOfStatement.initializer;
66534                 if (!checkGrammarVariableDeclarationList(variableList)) {
66535                     var declarations = variableList.declarations;
66536                     if (!declarations.length) {
66537                         return false;
66538                     }
66539                     if (declarations.length > 1) {
66540                         var diagnostic = forInOrOfStatement.kind === 238
66541                             ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement
66542                             : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement;
66543                         return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic);
66544                     }
66545                     var firstDeclaration = declarations[0];
66546                     if (firstDeclaration.initializer) {
66547                         var diagnostic = forInOrOfStatement.kind === 238
66548                             ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer
66549                             : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer;
66550                         return grammarErrorOnNode(firstDeclaration.name, diagnostic);
66551                     }
66552                     if (firstDeclaration.type) {
66553                         var diagnostic = forInOrOfStatement.kind === 238
66554                             ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation
66555                             : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation;
66556                         return grammarErrorOnNode(firstDeclaration, diagnostic);
66557                     }
66558                 }
66559             }
66560             return false;
66561         }
66562         function checkGrammarAccessor(accessor) {
66563             if (!(accessor.flags & 8388608)) {
66564                 if (languageVersion < 1) {
66565                     return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher);
66566                 }
66567                 if (accessor.body === undefined && !ts.hasSyntacticModifier(accessor, 128)) {
66568                     return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{");
66569                 }
66570             }
66571             if (accessor.body && ts.hasSyntacticModifier(accessor, 128)) {
66572                 return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation);
66573             }
66574             if (accessor.typeParameters) {
66575                 return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters);
66576             }
66577             if (!doesAccessorHaveCorrectParameterCount(accessor)) {
66578                 return grammarErrorOnNode(accessor.name, accessor.kind === 167 ?
66579                     ts.Diagnostics.A_get_accessor_cannot_have_parameters :
66580                     ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter);
66581             }
66582             if (accessor.kind === 168) {
66583                 if (accessor.type) {
66584                     return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation);
66585                 }
66586                 var parameter = ts.Debug.checkDefined(ts.getSetAccessorValueParameter(accessor), "Return value does not match parameter count assertion.");
66587                 if (parameter.dotDotDotToken) {
66588                     return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter);
66589                 }
66590                 if (parameter.questionToken) {
66591                     return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter);
66592                 }
66593                 if (parameter.initializer) {
66594                     return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer);
66595                 }
66596             }
66597             return false;
66598         }
66599         function doesAccessorHaveCorrectParameterCount(accessor) {
66600             return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 167 ? 0 : 1);
66601         }
66602         function getAccessorThisParameter(accessor) {
66603             if (accessor.parameters.length === (accessor.kind === 167 ? 1 : 2)) {
66604                 return ts.getThisParameter(accessor);
66605             }
66606         }
66607         function checkGrammarTypeOperatorNode(node) {
66608             if (node.operator === 151) {
66609                 if (node.type.kind !== 148) {
66610                     return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(148));
66611                 }
66612                 var parent = ts.walkUpParenthesizedTypes(node.parent);
66613                 if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) {
66614                     parent = parent.parent;
66615                     if (ts.isJSDocTypeTag(parent)) {
66616                         parent = parent.parent.parent;
66617                     }
66618                 }
66619                 switch (parent.kind) {
66620                     case 249:
66621                         var decl = parent;
66622                         if (decl.name.kind !== 78) {
66623                             return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name);
66624                         }
66625                         if (!ts.isVariableDeclarationInVariableStatement(decl)) {
66626                             return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement);
66627                         }
66628                         if (!(decl.parent.flags & 2)) {
66629                             return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const);
66630                         }
66631                         break;
66632                     case 163:
66633                         if (!ts.hasSyntacticModifier(parent, 32) ||
66634                             !ts.hasEffectiveModifier(parent, 64)) {
66635                             return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly);
66636                         }
66637                         break;
66638                     case 162:
66639                         if (!ts.hasSyntacticModifier(parent, 64)) {
66640                             return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly);
66641                         }
66642                         break;
66643                     default:
66644                         return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here);
66645                 }
66646             }
66647             else if (node.operator === 142) {
66648                 if (node.type.kind !== 178 && node.type.kind !== 179) {
66649                     return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(148));
66650                 }
66651             }
66652         }
66653         function checkGrammarForInvalidDynamicName(node, message) {
66654             if (isNonBindableDynamicName(node)) {
66655                 return grammarErrorOnNode(node, message);
66656             }
66657         }
66658         function checkGrammarMethod(node) {
66659             if (checkGrammarFunctionLikeDeclaration(node)) {
66660                 return true;
66661             }
66662             if (node.kind === 165) {
66663                 if (node.parent.kind === 200) {
66664                     if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 129)) {
66665                         return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here);
66666                     }
66667                     else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) {
66668                         return true;
66669                     }
66670                     else if (checkGrammarForInvalidExclamationToken(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context)) {
66671                         return true;
66672                     }
66673                     else if (node.body === undefined) {
66674                         return grammarErrorAtPos(node, node.end - 1, ";".length, ts.Diagnostics._0_expected, "{");
66675                     }
66676                 }
66677                 if (checkGrammarForGenerator(node)) {
66678                     return true;
66679                 }
66680             }
66681             if (ts.isClassLike(node.parent)) {
66682                 if (node.flags & 8388608) {
66683                     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);
66684                 }
66685                 else if (node.kind === 165 && !node.body) {
66686                     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);
66687                 }
66688             }
66689             else if (node.parent.kind === 253) {
66690                 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);
66691             }
66692             else if (node.parent.kind === 177) {
66693                 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);
66694             }
66695         }
66696         function checkGrammarBreakOrContinueStatement(node) {
66697             var current = node;
66698             while (current) {
66699                 if (ts.isFunctionLike(current)) {
66700                     return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary);
66701                 }
66702                 switch (current.kind) {
66703                     case 245:
66704                         if (node.label && current.label.escapedText === node.label.escapedText) {
66705                             var isMisplacedContinueLabel = node.kind === 240
66706                                 && !ts.isIterationStatement(current.statement, true);
66707                             if (isMisplacedContinueLabel) {
66708                                 return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement);
66709                             }
66710                             return false;
66711                         }
66712                         break;
66713                     case 244:
66714                         if (node.kind === 241 && !node.label) {
66715                             return false;
66716                         }
66717                         break;
66718                     default:
66719                         if (ts.isIterationStatement(current, false) && !node.label) {
66720                             return false;
66721                         }
66722                         break;
66723                 }
66724                 current = current.parent;
66725             }
66726             if (node.label) {
66727                 var message = node.kind === 241
66728                     ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement
66729                     : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement;
66730                 return grammarErrorOnNode(node, message);
66731             }
66732             else {
66733                 var message = node.kind === 241
66734                     ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement
66735                     : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement;
66736                 return grammarErrorOnNode(node, message);
66737             }
66738         }
66739         function checkGrammarBindingElement(node) {
66740             if (node.dotDotDotToken) {
66741                 var elements = node.parent.elements;
66742                 if (node !== ts.last(elements)) {
66743                     return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
66744                 }
66745                 checkGrammarForDisallowedTrailingComma(elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
66746                 if (node.propertyName) {
66747                     return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_have_a_property_name);
66748                 }
66749             }
66750             if (node.dotDotDotToken && node.initializer) {
66751                 return grammarErrorAtPos(node, node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer);
66752             }
66753         }
66754         function isStringOrNumberLiteralExpression(expr) {
66755             return ts.isStringOrNumericLiteralLike(expr) ||
66756                 expr.kind === 214 && expr.operator === 40 &&
66757                     expr.operand.kind === 8;
66758         }
66759         function isBigIntLiteralExpression(expr) {
66760             return expr.kind === 9 ||
66761                 expr.kind === 214 && expr.operator === 40 &&
66762                     expr.operand.kind === 9;
66763         }
66764         function isSimpleLiteralEnumReference(expr) {
66765             if ((ts.isPropertyAccessExpression(expr) || (ts.isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression))) &&
66766                 ts.isEntityNameExpression(expr.expression)) {
66767                 return !!(checkExpressionCached(expr).flags & 1024);
66768             }
66769         }
66770         function checkAmbientInitializer(node) {
66771             var initializer = node.initializer;
66772             if (initializer) {
66773                 var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) ||
66774                     isSimpleLiteralEnumReference(initializer) ||
66775                     initializer.kind === 109 || initializer.kind === 94 ||
66776                     isBigIntLiteralExpression(initializer));
66777                 var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node);
66778                 if (isConstOrReadonly && !node.type) {
66779                     if (isInvalidInitializer) {
66780                         return grammarErrorOnNode(initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference);
66781                     }
66782                 }
66783                 else {
66784                     return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
66785                 }
66786                 if (!isConstOrReadonly || isInvalidInitializer) {
66787                     return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
66788                 }
66789             }
66790         }
66791         function checkGrammarVariableDeclaration(node) {
66792             if (node.parent.parent.kind !== 238 && node.parent.parent.kind !== 239) {
66793                 if (node.flags & 8388608) {
66794                     checkAmbientInitializer(node);
66795                 }
66796                 else if (!node.initializer) {
66797                     if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) {
66798                         return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer);
66799                     }
66800                     if (ts.isVarConst(node)) {
66801                         return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized);
66802                     }
66803                 }
66804             }
66805             if (node.exclamationToken && (node.parent.parent.kind !== 232 || !node.type || node.initializer || node.flags & 8388608)) {
66806                 var message = node.initializer
66807                     ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
66808                     : ts.Diagnostics.Declarations_with_definite_assignment_assertions_must_also_have_type_annotations;
66809                 return grammarErrorOnNode(node.exclamationToken, message);
66810             }
66811             var moduleKind = ts.getEmitModuleKind(compilerOptions);
66812             if (moduleKind < ts.ModuleKind.ES2015 && moduleKind !== ts.ModuleKind.System &&
66813                 !(node.parent.parent.flags & 8388608) && ts.hasSyntacticModifier(node.parent.parent, 1)) {
66814                 checkESModuleMarker(node.name);
66815             }
66816             var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node));
66817             return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name);
66818         }
66819         function checkESModuleMarker(name) {
66820             if (name.kind === 78) {
66821                 if (ts.idText(name) === "__esModule") {
66822                     return grammarErrorOnNodeSkippedOn("noEmit", name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules);
66823                 }
66824             }
66825             else {
66826                 var elements = name.elements;
66827                 for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) {
66828                     var element = elements_1[_i];
66829                     if (!ts.isOmittedExpression(element)) {
66830                         return checkESModuleMarker(element.name);
66831                     }
66832                 }
66833             }
66834             return false;
66835         }
66836         function checkGrammarNameInLetOrConstDeclarations(name) {
66837             if (name.kind === 78) {
66838                 if (name.originalKeywordKind === 118) {
66839                     return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations);
66840                 }
66841             }
66842             else {
66843                 var elements = name.elements;
66844                 for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) {
66845                     var element = elements_2[_i];
66846                     if (!ts.isOmittedExpression(element)) {
66847                         checkGrammarNameInLetOrConstDeclarations(element.name);
66848                     }
66849                 }
66850             }
66851             return false;
66852         }
66853         function checkGrammarVariableDeclarationList(declarationList) {
66854             var declarations = declarationList.declarations;
66855             if (checkGrammarForDisallowedTrailingComma(declarationList.declarations)) {
66856                 return true;
66857             }
66858             if (!declarationList.declarations.length) {
66859                 return grammarErrorAtPos(declarationList, declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty);
66860             }
66861             return false;
66862         }
66863         function allowLetAndConstDeclarations(parent) {
66864             switch (parent.kind) {
66865                 case 234:
66866                 case 235:
66867                 case 236:
66868                 case 243:
66869                 case 237:
66870                 case 238:
66871                 case 239:
66872                     return false;
66873                 case 245:
66874                     return allowLetAndConstDeclarations(parent.parent);
66875             }
66876             return true;
66877         }
66878         function checkGrammarForDisallowedLetOrConstStatement(node) {
66879             if (!allowLetAndConstDeclarations(node.parent)) {
66880                 if (ts.isLet(node.declarationList)) {
66881                     return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block);
66882                 }
66883                 else if (ts.isVarConst(node.declarationList)) {
66884                     return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block);
66885                 }
66886             }
66887         }
66888         function checkGrammarMetaProperty(node) {
66889             var escapedText = node.name.escapedText;
66890             switch (node.keywordToken) {
66891                 case 102:
66892                     if (escapedText !== "target") {
66893                         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");
66894                     }
66895                     break;
66896                 case 99:
66897                     if (escapedText !== "meta") {
66898                         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");
66899                     }
66900                     break;
66901             }
66902         }
66903         function hasParseDiagnostics(sourceFile) {
66904             return sourceFile.parseDiagnostics.length > 0;
66905         }
66906         function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) {
66907             var sourceFile = ts.getSourceFileOfNode(node);
66908             if (!hasParseDiagnostics(sourceFile)) {
66909                 var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
66910                 diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2));
66911                 return true;
66912             }
66913             return false;
66914         }
66915         function grammarErrorAtPos(nodeForSourceFile, start, length, message, arg0, arg1, arg2) {
66916             var sourceFile = ts.getSourceFileOfNode(nodeForSourceFile);
66917             if (!hasParseDiagnostics(sourceFile)) {
66918                 diagnostics.add(ts.createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2));
66919                 return true;
66920             }
66921             return false;
66922         }
66923         function grammarErrorOnNodeSkippedOn(key, node, message, arg0, arg1, arg2) {
66924             var sourceFile = ts.getSourceFileOfNode(node);
66925             if (!hasParseDiagnostics(sourceFile)) {
66926                 errorSkippedOn(key, node, message, arg0, arg1, arg2);
66927                 return true;
66928             }
66929             return false;
66930         }
66931         function grammarErrorOnNode(node, message, arg0, arg1, arg2) {
66932             var sourceFile = ts.getSourceFileOfNode(node);
66933             if (!hasParseDiagnostics(sourceFile)) {
66934                 diagnostics.add(ts.createDiagnosticForNode(node, message, arg0, arg1, arg2));
66935                 return true;
66936             }
66937             return false;
66938         }
66939         function checkGrammarConstructorTypeParameters(node) {
66940             var jsdocTypeParameters = ts.isInJSFile(node) ? ts.getJSDocTypeParameterDeclarations(node) : undefined;
66941             var range = node.typeParameters || jsdocTypeParameters && ts.firstOrUndefined(jsdocTypeParameters);
66942             if (range) {
66943                 var pos = range.pos === range.end ? range.pos : ts.skipTrivia(ts.getSourceFileOfNode(node).text, range.pos);
66944                 return grammarErrorAtPos(node, pos, range.end - pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration);
66945             }
66946         }
66947         function checkGrammarConstructorTypeAnnotation(node) {
66948             var type = ts.getEffectiveReturnTypeNode(node);
66949             if (type) {
66950                 return grammarErrorOnNode(type, ts.Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration);
66951             }
66952         }
66953         function checkGrammarProperty(node) {
66954             if (ts.isClassLike(node.parent)) {
66955                 if (ts.isStringLiteral(node.name) && node.name.text === "constructor") {
66956                     return grammarErrorOnNode(node.name, ts.Diagnostics.Classes_may_not_have_a_field_named_constructor);
66957                 }
66958                 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)) {
66959                     return true;
66960                 }
66961                 if (languageVersion < 2 && ts.isPrivateIdentifier(node.name)) {
66962                     return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher);
66963                 }
66964             }
66965             else if (node.parent.kind === 253) {
66966                 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)) {
66967                     return true;
66968                 }
66969                 if (node.initializer) {
66970                     return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer);
66971                 }
66972             }
66973             else if (node.parent.kind === 177) {
66974                 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)) {
66975                     return true;
66976                 }
66977                 if (node.initializer) {
66978                     return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer);
66979                 }
66980             }
66981             if (node.flags & 8388608) {
66982                 checkAmbientInitializer(node);
66983             }
66984             if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer ||
66985                 node.flags & 8388608 || ts.hasSyntacticModifier(node, 32 | 128))) {
66986                 var message = node.initializer
66987                     ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
66988                     : !node.type
66989                         ? ts.Diagnostics.Declarations_with_definite_assignment_assertions_must_also_have_type_annotations
66990                         : ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context;
66991                 return grammarErrorOnNode(node.exclamationToken, message);
66992             }
66993         }
66994         function checkGrammarTopLevelElementForRequiredDeclareModifier(node) {
66995             if (node.kind === 253 ||
66996                 node.kind === 254 ||
66997                 node.kind === 261 ||
66998                 node.kind === 260 ||
66999                 node.kind === 267 ||
67000                 node.kind === 266 ||
67001                 node.kind === 259 ||
67002                 ts.hasSyntacticModifier(node, 2 | 1 | 512)) {
67003                 return false;
67004             }
67005             return grammarErrorOnFirstToken(node, ts.Diagnostics.Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier);
67006         }
67007         function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) {
67008             for (var _i = 0, _a = file.statements; _i < _a.length; _i++) {
67009                 var decl = _a[_i];
67010                 if (ts.isDeclaration(decl) || decl.kind === 232) {
67011                     if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) {
67012                         return true;
67013                     }
67014                 }
67015             }
67016             return false;
67017         }
67018         function checkGrammarSourceFile(node) {
67019             return !!(node.flags & 8388608) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node);
67020         }
67021         function checkGrammarStatementInAmbientContext(node) {
67022             if (node.flags & 8388608) {
67023                 var links = getNodeLinks(node);
67024                 if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) {
67025                     return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts);
67026                 }
67027                 if (node.parent.kind === 230 || node.parent.kind === 257 || node.parent.kind === 297) {
67028                     var links_2 = getNodeLinks(node.parent);
67029                     if (!links_2.hasReportedStatementInAmbientContext) {
67030                         return links_2.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts);
67031                     }
67032                 }
67033                 else {
67034                 }
67035             }
67036             return false;
67037         }
67038         function checkGrammarNumericLiteral(node) {
67039             if (node.numericLiteralFlags & 32) {
67040                 var diagnosticMessage = void 0;
67041                 if (languageVersion >= 1) {
67042                     diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0;
67043                 }
67044                 else if (ts.isChildOfNodeWithKind(node, 191)) {
67045                     diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0;
67046                 }
67047                 else if (ts.isChildOfNodeWithKind(node, 291)) {
67048                     diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0;
67049                 }
67050                 if (diagnosticMessage) {
67051                     var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40;
67052                     var literal = (withMinus ? "-" : "") + "0o" + node.text;
67053                     return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal);
67054                 }
67055             }
67056             checkNumericLiteralValueSize(node);
67057             return false;
67058         }
67059         function checkNumericLiteralValueSize(node) {
67060             if (node.numericLiteralFlags & 16 || node.text.length <= 15 || node.text.indexOf(".") !== -1) {
67061                 return;
67062             }
67063             var apparentValue = +ts.getTextOfNode(node);
67064             if (apparentValue <= Math.pow(2, 53) - 1 && apparentValue + 1 > apparentValue) {
67065                 return;
67066             }
67067             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));
67068         }
67069         function checkGrammarBigIntLiteral(node) {
67070             var literalType = ts.isLiteralTypeNode(node.parent) ||
67071                 ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent);
67072             if (!literalType) {
67073                 if (languageVersion < 7) {
67074                     if (grammarErrorOnNode(node, ts.Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ES2020)) {
67075                         return true;
67076                     }
67077                 }
67078             }
67079             return false;
67080         }
67081         function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) {
67082             var sourceFile = ts.getSourceFileOfNode(node);
67083             if (!hasParseDiagnostics(sourceFile)) {
67084                 var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
67085                 diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), 0, message, arg0, arg1, arg2));
67086                 return true;
67087             }
67088             return false;
67089         }
67090         function getAmbientModules() {
67091             if (!ambientModulesCache) {
67092                 ambientModulesCache = [];
67093                 globals.forEach(function (global, sym) {
67094                     if (ambientModuleSymbolRegex.test(sym)) {
67095                         ambientModulesCache.push(global);
67096                     }
67097                 });
67098             }
67099             return ambientModulesCache;
67100         }
67101         function checkGrammarImportClause(node) {
67102             if (node.isTypeOnly && node.name && node.namedBindings) {
67103                 return grammarErrorOnNode(node, ts.Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both);
67104             }
67105             return false;
67106         }
67107         function checkGrammarImportCallExpression(node) {
67108             if (moduleKind === ts.ModuleKind.ES2015) {
67109                 return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_esnext_commonjs_amd_system_or_umd);
67110             }
67111             if (node.typeArguments) {
67112                 return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments);
67113             }
67114             var nodeArguments = node.arguments;
67115             if (nodeArguments.length !== 1) {
67116                 return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_must_have_one_specifier_as_an_argument);
67117             }
67118             checkGrammarForDisallowedTrailingComma(nodeArguments);
67119             if (ts.isSpreadElement(nodeArguments[0])) {
67120                 return grammarErrorOnNode(nodeArguments[0], ts.Diagnostics.Specifier_of_dynamic_import_cannot_be_spread_element);
67121             }
67122             return false;
67123         }
67124         function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) {
67125             var sourceObjectFlags = ts.getObjectFlags(source);
67126             if (sourceObjectFlags & (4 | 16) && unionTarget.flags & 1048576) {
67127                 return ts.find(unionTarget.types, function (target) {
67128                     if (target.flags & 524288) {
67129                         var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target);
67130                         if (overlapObjFlags & 4) {
67131                             return source.target === target.target;
67132                         }
67133                         if (overlapObjFlags & 16) {
67134                             return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol;
67135                         }
67136                     }
67137                     return false;
67138                 });
67139             }
67140         }
67141         function findBestTypeForObjectLiteral(source, unionTarget) {
67142             if (ts.getObjectFlags(source) & 128 && forEachType(unionTarget, isArrayLikeType)) {
67143                 return ts.find(unionTarget.types, function (t) { return !isArrayLikeType(t); });
67144             }
67145         }
67146         function findBestTypeForInvokable(source, unionTarget) {
67147             var signatureKind = 0;
67148             var hasSignatures = getSignaturesOfType(source, signatureKind).length > 0 ||
67149                 (signatureKind = 1, getSignaturesOfType(source, signatureKind).length > 0);
67150             if (hasSignatures) {
67151                 return ts.find(unionTarget.types, function (t) { return getSignaturesOfType(t, signatureKind).length > 0; });
67152             }
67153         }
67154         function findMostOverlappyType(source, unionTarget) {
67155             var bestMatch;
67156             var matchingCount = 0;
67157             for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) {
67158                 var target = _a[_i];
67159                 var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]);
67160                 if (overlap.flags & 4194304) {
67161                     bestMatch = target;
67162                     matchingCount = Infinity;
67163                 }
67164                 else if (overlap.flags & 1048576) {
67165                     var len = ts.length(ts.filter(overlap.types, isUnitType));
67166                     if (len >= matchingCount) {
67167                         bestMatch = target;
67168                         matchingCount = len;
67169                     }
67170                 }
67171                 else if (isUnitType(overlap) && 1 >= matchingCount) {
67172                     bestMatch = target;
67173                     matchingCount = 1;
67174                 }
67175             }
67176             return bestMatch;
67177         }
67178         function filterPrimitivesIfContainsNonPrimitive(type) {
67179             if (maybeTypeOfKind(type, 67108864)) {
67180                 var result = filterType(type, function (t) { return !(t.flags & 131068); });
67181                 if (!(result.flags & 131072)) {
67182                     return result;
67183                 }
67184             }
67185             return type;
67186         }
67187         function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) {
67188             if (target.flags & 1048576 && source.flags & (2097152 | 524288)) {
67189                 var sourceProperties = getPropertiesOfType(source);
67190                 if (sourceProperties) {
67191                     var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
67192                     if (sourcePropertiesFiltered) {
67193                         return discriminateTypeByDiscriminableItems(target, ts.map(sourcePropertiesFiltered, function (p) { return [function () { return getTypeOfSymbol(p); }, p.escapedName]; }), isRelatedTo, undefined, skipPartial);
67194                     }
67195                 }
67196             }
67197             return undefined;
67198         }
67199     }
67200     ts.createTypeChecker = createTypeChecker;
67201     function isNotAccessor(declaration) {
67202         return !ts.isAccessor(declaration);
67203     }
67204     function isNotOverload(declaration) {
67205         return (declaration.kind !== 251 && declaration.kind !== 165) ||
67206             !!declaration.body;
67207     }
67208     function isDeclarationNameOrImportPropertyName(name) {
67209         switch (name.parent.kind) {
67210             case 265:
67211             case 270:
67212                 return ts.isIdentifier(name);
67213             default:
67214                 return ts.isDeclarationName(name);
67215         }
67216     }
67217     function isSomeImportDeclaration(decl) {
67218         switch (decl.kind) {
67219             case 262:
67220             case 260:
67221             case 263:
67222             case 265:
67223                 return true;
67224             case 78:
67225                 return decl.parent.kind === 265;
67226             default:
67227                 return false;
67228         }
67229     }
67230     var JsxNames;
67231     (function (JsxNames) {
67232         JsxNames.JSX = "JSX";
67233         JsxNames.IntrinsicElements = "IntrinsicElements";
67234         JsxNames.ElementClass = "ElementClass";
67235         JsxNames.ElementAttributesPropertyNameContainer = "ElementAttributesProperty";
67236         JsxNames.ElementChildrenAttributeNameContainer = "ElementChildrenAttribute";
67237         JsxNames.Element = "Element";
67238         JsxNames.IntrinsicAttributes = "IntrinsicAttributes";
67239         JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes";
67240         JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes";
67241     })(JsxNames || (JsxNames = {}));
67242     function getIterationTypesKeyFromIterationTypeKind(typeKind) {
67243         switch (typeKind) {
67244             case 0: return "yieldType";
67245             case 1: return "returnType";
67246             case 2: return "nextType";
67247         }
67248     }
67249     function signatureHasRestParameter(s) {
67250         return !!(s.flags & 1);
67251     }
67252     ts.signatureHasRestParameter = signatureHasRestParameter;
67253     function signatureHasLiteralTypes(s) {
67254         return !!(s.flags & 2);
67255     }
67256     ts.signatureHasLiteralTypes = signatureHasLiteralTypes;
67257 })(ts || (ts = {}));
67258 var ts;
67259 (function (ts) {
67260     var isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration);
67261     function visitNode(node, visitor, test, lift) {
67262         if (node === undefined || visitor === undefined) {
67263             return node;
67264         }
67265         var visited = visitor(node);
67266         if (visited === node) {
67267             return node;
67268         }
67269         var visitedNode;
67270         if (visited === undefined) {
67271             return undefined;
67272         }
67273         else if (ts.isArray(visited)) {
67274             visitedNode = (lift || extractSingleNode)(visited);
67275         }
67276         else {
67277             visitedNode = visited;
67278         }
67279         ts.Debug.assertNode(visitedNode, test);
67280         return visitedNode;
67281     }
67282     ts.visitNode = visitNode;
67283     function visitNodes(nodes, visitor, test, start, count) {
67284         if (nodes === undefined || visitor === undefined) {
67285             return nodes;
67286         }
67287         var updated;
67288         var length = nodes.length;
67289         if (start === undefined || start < 0) {
67290             start = 0;
67291         }
67292         if (count === undefined || count > length - start) {
67293             count = length - start;
67294         }
67295         var hasTrailingComma;
67296         var pos = -1;
67297         var end = -1;
67298         if (start > 0 || count < length) {
67299             updated = [];
67300             hasTrailingComma = nodes.hasTrailingComma && start + count === length;
67301         }
67302         for (var i = 0; i < count; i++) {
67303             var node = nodes[i + start];
67304             var visited = node !== undefined ? visitor(node) : undefined;
67305             if (updated !== undefined || visited === undefined || visited !== node) {
67306                 if (updated === undefined) {
67307                     updated = nodes.slice(0, i);
67308                     hasTrailingComma = nodes.hasTrailingComma;
67309                     pos = nodes.pos;
67310                     end = nodes.end;
67311                 }
67312                 if (visited) {
67313                     if (ts.isArray(visited)) {
67314                         for (var _i = 0, visited_1 = visited; _i < visited_1.length; _i++) {
67315                             var visitedNode = visited_1[_i];
67316                             void ts.Debug.assertNode(visitedNode, test);
67317                             updated.push(visitedNode);
67318                         }
67319                     }
67320                     else {
67321                         void ts.Debug.assertNode(visited, test);
67322                         updated.push(visited);
67323                     }
67324                 }
67325             }
67326         }
67327         if (updated) {
67328             var updatedArray = ts.factory.createNodeArray(updated, hasTrailingComma);
67329             ts.setTextRangePosEnd(updatedArray, pos, end);
67330             return updatedArray;
67331         }
67332         return nodes;
67333     }
67334     ts.visitNodes = visitNodes;
67335     function visitLexicalEnvironment(statements, visitor, context, start, ensureUseStrict, nodesVisitor) {
67336         if (nodesVisitor === void 0) { nodesVisitor = visitNodes; }
67337         context.startLexicalEnvironment();
67338         statements = nodesVisitor(statements, visitor, ts.isStatement, start);
67339         if (ensureUseStrict)
67340             statements = context.factory.ensureUseStrict(statements);
67341         return ts.factory.mergeLexicalEnvironment(statements, context.endLexicalEnvironment());
67342     }
67343     ts.visitLexicalEnvironment = visitLexicalEnvironment;
67344     function visitParameterList(nodes, visitor, context, nodesVisitor) {
67345         if (nodesVisitor === void 0) { nodesVisitor = visitNodes; }
67346         var updated;
67347         context.startLexicalEnvironment();
67348         if (nodes) {
67349             context.setLexicalEnvironmentFlags(1, true);
67350             updated = nodesVisitor(nodes, visitor, ts.isParameterDeclaration);
67351             if (context.getLexicalEnvironmentFlags() & 2 &&
67352                 ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2) {
67353                 updated = addDefaultValueAssignmentsIfNeeded(updated, context);
67354             }
67355             context.setLexicalEnvironmentFlags(1, false);
67356         }
67357         context.suspendLexicalEnvironment();
67358         return updated;
67359     }
67360     ts.visitParameterList = visitParameterList;
67361     function addDefaultValueAssignmentsIfNeeded(parameters, context) {
67362         var result;
67363         for (var i = 0; i < parameters.length; i++) {
67364             var parameter = parameters[i];
67365             var updated = addDefaultValueAssignmentIfNeeded(parameter, context);
67366             if (result || updated !== parameter) {
67367                 if (!result)
67368                     result = parameters.slice(0, i);
67369                 result[i] = updated;
67370             }
67371         }
67372         if (result) {
67373             return ts.setTextRange(context.factory.createNodeArray(result, parameters.hasTrailingComma), parameters);
67374         }
67375         return parameters;
67376     }
67377     function addDefaultValueAssignmentIfNeeded(parameter, context) {
67378         return parameter.dotDotDotToken ? parameter :
67379             ts.isBindingPattern(parameter.name) ? addDefaultValueAssignmentForBindingPattern(parameter, context) :
67380                 parameter.initializer ? addDefaultValueAssignmentForInitializer(parameter, parameter.name, parameter.initializer, context) :
67381                     parameter;
67382     }
67383     function addDefaultValueAssignmentForBindingPattern(parameter, context) {
67384         var factory = context.factory;
67385         context.addInitializationStatement(factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
67386             factory.createVariableDeclaration(parameter.name, undefined, parameter.type, parameter.initializer ?
67387                 factory.createConditionalExpression(factory.createStrictEquality(factory.getGeneratedNameForNode(parameter), factory.createVoidZero()), undefined, parameter.initializer, undefined, factory.getGeneratedNameForNode(parameter)) :
67388                 factory.getGeneratedNameForNode(parameter)),
67389         ])));
67390         return factory.updateParameterDeclaration(parameter, parameter.decorators, parameter.modifiers, parameter.dotDotDotToken, factory.getGeneratedNameForNode(parameter), parameter.questionToken, parameter.type, undefined);
67391     }
67392     function addDefaultValueAssignmentForInitializer(parameter, name, initializer, context) {
67393         var factory = context.factory;
67394         context.addInitializationStatement(factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([
67395             factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(ts.setEmitFlags(factory.cloneNode(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer) | 1536)), parameter), 1536))
67396         ]), parameter), 1 | 32 | 384 | 1536)));
67397         return factory.updateParameterDeclaration(parameter, parameter.decorators, parameter.modifiers, parameter.dotDotDotToken, parameter.name, parameter.questionToken, parameter.type, undefined);
67398     }
67399     function visitFunctionBody(node, visitor, context, nodeVisitor) {
67400         if (nodeVisitor === void 0) { nodeVisitor = visitNode; }
67401         context.resumeLexicalEnvironment();
67402         var updated = nodeVisitor(node, visitor, ts.isConciseBody);
67403         var declarations = context.endLexicalEnvironment();
67404         if (ts.some(declarations)) {
67405             if (!updated) {
67406                 return context.factory.createBlock(declarations);
67407             }
67408             var block = context.factory.converters.convertToFunctionBlock(updated);
67409             var statements = ts.factory.mergeLexicalEnvironment(block.statements, declarations);
67410             return context.factory.updateBlock(block, statements);
67411         }
67412         return updated;
67413     }
67414     ts.visitFunctionBody = visitFunctionBody;
67415     function visitEachChild(node, visitor, context, nodesVisitor, tokenVisitor, nodeVisitor) {
67416         if (nodesVisitor === void 0) { nodesVisitor = visitNodes; }
67417         if (nodeVisitor === void 0) { nodeVisitor = visitNode; }
67418         if (node === undefined) {
67419             return undefined;
67420         }
67421         var kind = node.kind;
67422         if ((kind > 0 && kind <= 156) || kind === 187) {
67423             return node;
67424         }
67425         var factory = context.factory;
67426         switch (kind) {
67427             case 78:
67428                 return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration));
67429             case 157:
67430                 return factory.updateQualifiedName(node, nodeVisitor(node.left, visitor, ts.isEntityName), nodeVisitor(node.right, visitor, ts.isIdentifier));
67431             case 158:
67432                 return factory.updateComputedPropertyName(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67433             case 159:
67434                 return factory.updateTypeParameterDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.constraint, visitor, ts.isTypeNode), nodeVisitor(node.default, visitor, ts.isTypeNode));
67435             case 160:
67436                 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));
67437             case 161:
67438                 return factory.updateDecorator(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67439             case 162:
67440                 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));
67441             case 163:
67442                 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));
67443             case 164:
67444                 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));
67445             case 165:
67446                 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));
67447             case 166:
67448                 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));
67449             case 167:
67450                 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));
67451             case 168:
67452                 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));
67453             case 169:
67454                 return factory.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode));
67455             case 170:
67456                 return factory.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode));
67457             case 171:
67458                 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));
67459             case 172:
67460                 return factory.updateTypePredicateNode(node, nodeVisitor(node.assertsModifier, visitor), nodeVisitor(node.parameterName, visitor), nodeVisitor(node.type, visitor, ts.isTypeNode));
67461             case 173:
67462                 return factory.updateTypeReferenceNode(node, nodeVisitor(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode));
67463             case 174:
67464                 return factory.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode));
67465             case 175:
67466                 return factory.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode));
67467             case 176:
67468                 return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName));
67469             case 177:
67470                 return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement));
67471             case 178:
67472                 return factory.updateArrayTypeNode(node, nodeVisitor(node.elementType, visitor, ts.isTypeNode));
67473             case 179:
67474                 return factory.updateTupleTypeNode(node, nodesVisitor(node.elements, visitor, ts.isTypeNode));
67475             case 180:
67476                 return factory.updateOptionalTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
67477             case 181:
67478                 return factory.updateRestTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
67479             case 182:
67480                 return factory.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode));
67481             case 183:
67482                 return factory.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode));
67483             case 184:
67484                 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));
67485             case 185:
67486                 return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration));
67487             case 195:
67488                 return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf);
67489             case 192:
67490                 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));
67491             case 186:
67492                 return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
67493             case 188:
67494                 return factory.updateTypeOperatorNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
67495             case 189:
67496                 return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode));
67497             case 190:
67498                 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));
67499             case 191:
67500                 return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression));
67501             case 193:
67502                 return factory.updateTemplateLiteralType(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateLiteralTypeSpan));
67503             case 194:
67504                 return factory.updateTemplateLiteralTypeSpan(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail));
67505             case 196:
67506                 return factory.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement));
67507             case 197:
67508                 return factory.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement));
67509             case 198:
67510                 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));
67511             case 199:
67512                 return factory.updateArrayLiteralExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression));
67513             case 200:
67514                 return factory.updateObjectLiteralExpression(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike));
67515             case 201:
67516                 if (node.flags & 32) {
67517                     return factory.updatePropertyAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isIdentifier));
67518                 }
67519                 return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isIdentifierOrPrivateIdentifier));
67520             case 202:
67521                 if (node.flags & 32) {
67522                     return factory.updateElementAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.argumentExpression, visitor, ts.isExpression));
67523                 }
67524                 return factory.updateElementAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.argumentExpression, visitor, ts.isExpression));
67525             case 203:
67526                 if (node.flags & 32) {
67527                     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));
67528                 }
67529                 return factory.updateCallExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
67530             case 204:
67531                 return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
67532             case 205:
67533                 return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), nodeVisitor(node.template, visitor, ts.isTemplateLiteral));
67534             case 206:
67535                 return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression));
67536             case 207:
67537                 return factory.updateParenthesizedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67538             case 208:
67539                 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));
67540             case 209:
67541                 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));
67542             case 210:
67543                 return factory.updateDeleteExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67544             case 211:
67545                 return factory.updateTypeOfExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67546             case 212:
67547                 return factory.updateVoidExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67548             case 213:
67549                 return factory.updateAwaitExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67550             case 214:
67551                 return factory.updatePrefixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression));
67552             case 215:
67553                 return factory.updatePostfixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression));
67554             case 216:
67555                 return factory.updateBinaryExpression(node, nodeVisitor(node.left, visitor, ts.isExpression), nodeVisitor(node.operatorToken, tokenVisitor, ts.isToken), nodeVisitor(node.right, visitor, ts.isExpression));
67556             case 217:
67557                 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));
67558             case 218:
67559                 return factory.updateTemplateExpression(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan));
67560             case 219:
67561                 return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), nodeVisitor(node.expression, visitor, ts.isExpression));
67562             case 220:
67563                 return factory.updateSpreadElement(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67564             case 221:
67565                 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));
67566             case 223:
67567                 return factory.updateExpressionWithTypeArguments(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode));
67568             case 224:
67569                 return factory.updateAsExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.type, visitor, ts.isTypeNode));
67570             case 225:
67571                 if (node.flags & 32) {
67572                     return factory.updateNonNullChain(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67573                 }
67574                 return factory.updateNonNullExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67575             case 226:
67576                 return factory.updateMetaProperty(node, nodeVisitor(node.name, visitor, ts.isIdentifier));
67577             case 228:
67578                 return factory.updateTemplateSpan(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail));
67579             case 230:
67580                 return factory.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement));
67581             case 232:
67582                 return factory.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.declarationList, visitor, ts.isVariableDeclarationList));
67583             case 233:
67584                 return factory.updateExpressionStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67585             case 234:
67586                 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));
67587             case 235:
67588                 return factory.updateDoStatement(node, nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock), nodeVisitor(node.expression, visitor, ts.isExpression));
67589             case 236:
67590                 return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock));
67591             case 237:
67592                 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));
67593             case 238:
67594                 return factory.updateForInStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock));
67595             case 239:
67596                 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));
67597             case 240:
67598                 return factory.updateContinueStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier));
67599             case 241:
67600                 return factory.updateBreakStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier));
67601             case 242:
67602                 return factory.updateReturnStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67603             case 243:
67604                 return factory.updateWithStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock));
67605             case 244:
67606                 return factory.updateSwitchStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.caseBlock, visitor, ts.isCaseBlock));
67607             case 245:
67608                 return factory.updateLabeledStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock));
67609             case 246:
67610                 return factory.updateThrowStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67611             case 247:
67612                 return factory.updateTryStatement(node, nodeVisitor(node.tryBlock, visitor, ts.isBlock), nodeVisitor(node.catchClause, visitor, ts.isCatchClause), nodeVisitor(node.finallyBlock, visitor, ts.isBlock));
67613             case 249:
67614                 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));
67615             case 250:
67616                 return factory.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration));
67617             case 251:
67618                 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));
67619             case 252:
67620                 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));
67621             case 253:
67622                 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));
67623             case 254:
67624                 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));
67625             case 255:
67626                 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));
67627             case 256:
67628                 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));
67629             case 257:
67630                 return factory.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement));
67631             case 258:
67632                 return factory.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause));
67633             case 259:
67634                 return factory.updateNamespaceExportDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier));
67635             case 260:
67636                 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));
67637             case 261:
67638                 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));
67639             case 262:
67640                 return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings));
67641             case 263:
67642                 return factory.updateNamespaceImport(node, nodeVisitor(node.name, visitor, ts.isIdentifier));
67643             case 269:
67644                 return factory.updateNamespaceExport(node, nodeVisitor(node.name, visitor, ts.isIdentifier));
67645             case 264:
67646                 return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier));
67647             case 265:
67648                 return factory.updateImportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier));
67649             case 266:
67650                 return factory.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.expression, visitor, ts.isExpression));
67651             case 267:
67652                 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));
67653             case 268:
67654                 return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier));
67655             case 270:
67656                 return factory.updateExportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier));
67657             case 272:
67658                 return factory.updateExternalModuleReference(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67659             case 273:
67660                 return factory.updateJsxElement(node, nodeVisitor(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingElement, visitor, ts.isJsxClosingElement));
67661             case 274:
67662                 return factory.updateJsxSelfClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes));
67663             case 275:
67664                 return factory.updateJsxOpeningElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes));
67665             case 276:
67666                 return factory.updateJsxClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression));
67667             case 277:
67668                 return factory.updateJsxFragment(node, nodeVisitor(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingFragment, visitor, ts.isJsxClosingFragment));
67669             case 280:
67670                 return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression));
67671             case 281:
67672                 return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike));
67673             case 282:
67674                 return factory.updateJsxSpreadAttribute(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67675             case 283:
67676                 return factory.updateJsxExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67677             case 284:
67678                 return factory.updateCaseClause(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement));
67679             case 285:
67680                 return factory.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement));
67681             case 286:
67682                 return factory.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments));
67683             case 287:
67684                 return factory.updateCatchClause(node, nodeVisitor(node.variableDeclaration, visitor, ts.isVariableDeclaration), nodeVisitor(node.block, visitor, ts.isBlock));
67685             case 288:
67686                 return factory.updatePropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression));
67687             case 289:
67688                 return factory.updateShorthandPropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.objectAssignmentInitializer, visitor, ts.isExpression));
67689             case 290:
67690                 return factory.updateSpreadAssignment(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67691             case 291:
67692                 return factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression));
67693             case 297:
67694                 return factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context));
67695             case 336:
67696                 return factory.updatePartiallyEmittedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
67697             case 337:
67698                 return factory.updateCommaListExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression));
67699             default:
67700                 return node;
67701         }
67702     }
67703     ts.visitEachChild = visitEachChild;
67704     function extractSingleNode(nodes) {
67705         ts.Debug.assert(nodes.length <= 1, "Too many nodes written to output.");
67706         return ts.singleOrUndefined(nodes);
67707     }
67708 })(ts || (ts = {}));
67709 var ts;
67710 (function (ts) {
67711     function createSourceMapGenerator(host, file, sourceRoot, sourcesDirectoryPath, generatorOptions) {
67712         var _a = generatorOptions.extendedDiagnostics
67713             ? ts.performance.createTimer("Source Map", "beforeSourcemap", "afterSourcemap")
67714             : ts.performance.nullTimer, enter = _a.enter, exit = _a.exit;
67715         var rawSources = [];
67716         var sources = [];
67717         var sourceToSourceIndexMap = new ts.Map();
67718         var sourcesContent;
67719         var names = [];
67720         var nameToNameIndexMap;
67721         var mappings = "";
67722         var lastGeneratedLine = 0;
67723         var lastGeneratedCharacter = 0;
67724         var lastSourceIndex = 0;
67725         var lastSourceLine = 0;
67726         var lastSourceCharacter = 0;
67727         var lastNameIndex = 0;
67728         var hasLast = false;
67729         var pendingGeneratedLine = 0;
67730         var pendingGeneratedCharacter = 0;
67731         var pendingSourceIndex = 0;
67732         var pendingSourceLine = 0;
67733         var pendingSourceCharacter = 0;
67734         var pendingNameIndex = 0;
67735         var hasPending = false;
67736         var hasPendingSource = false;
67737         var hasPendingName = false;
67738         return {
67739             getSources: function () { return rawSources; },
67740             addSource: addSource,
67741             setSourceContent: setSourceContent,
67742             addName: addName,
67743             addMapping: addMapping,
67744             appendSourceMap: appendSourceMap,
67745             toJSON: toJSON,
67746             toString: function () { return JSON.stringify(toJSON()); }
67747         };
67748         function addSource(fileName) {
67749             enter();
67750             var source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true);
67751             var sourceIndex = sourceToSourceIndexMap.get(source);
67752             if (sourceIndex === undefined) {
67753                 sourceIndex = sources.length;
67754                 sources.push(source);
67755                 rawSources.push(fileName);
67756                 sourceToSourceIndexMap.set(source, sourceIndex);
67757             }
67758             exit();
67759             return sourceIndex;
67760         }
67761         function setSourceContent(sourceIndex, content) {
67762             enter();
67763             if (content !== null) {
67764                 if (!sourcesContent)
67765                     sourcesContent = [];
67766                 while (sourcesContent.length < sourceIndex) {
67767                     sourcesContent.push(null);
67768                 }
67769                 sourcesContent[sourceIndex] = content;
67770             }
67771             exit();
67772         }
67773         function addName(name) {
67774             enter();
67775             if (!nameToNameIndexMap)
67776                 nameToNameIndexMap = new ts.Map();
67777             var nameIndex = nameToNameIndexMap.get(name);
67778             if (nameIndex === undefined) {
67779                 nameIndex = names.length;
67780                 names.push(name);
67781                 nameToNameIndexMap.set(name, nameIndex);
67782             }
67783             exit();
67784             return nameIndex;
67785         }
67786         function isNewGeneratedPosition(generatedLine, generatedCharacter) {
67787             return !hasPending
67788                 || pendingGeneratedLine !== generatedLine
67789                 || pendingGeneratedCharacter !== generatedCharacter;
67790         }
67791         function isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter) {
67792             return sourceIndex !== undefined
67793                 && sourceLine !== undefined
67794                 && sourceCharacter !== undefined
67795                 && pendingSourceIndex === sourceIndex
67796                 && (pendingSourceLine > sourceLine
67797                     || pendingSourceLine === sourceLine && pendingSourceCharacter > sourceCharacter);
67798         }
67799         function addMapping(generatedLine, generatedCharacter, sourceIndex, sourceLine, sourceCharacter, nameIndex) {
67800             ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack");
67801             ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative");
67802             ts.Debug.assert(sourceIndex === undefined || sourceIndex >= 0, "sourceIndex cannot be negative");
67803             ts.Debug.assert(sourceLine === undefined || sourceLine >= 0, "sourceLine cannot be negative");
67804             ts.Debug.assert(sourceCharacter === undefined || sourceCharacter >= 0, "sourceCharacter cannot be negative");
67805             enter();
67806             if (isNewGeneratedPosition(generatedLine, generatedCharacter) ||
67807                 isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter)) {
67808                 commitPendingMapping();
67809                 pendingGeneratedLine = generatedLine;
67810                 pendingGeneratedCharacter = generatedCharacter;
67811                 hasPendingSource = false;
67812                 hasPendingName = false;
67813                 hasPending = true;
67814             }
67815             if (sourceIndex !== undefined && sourceLine !== undefined && sourceCharacter !== undefined) {
67816                 pendingSourceIndex = sourceIndex;
67817                 pendingSourceLine = sourceLine;
67818                 pendingSourceCharacter = sourceCharacter;
67819                 hasPendingSource = true;
67820                 if (nameIndex !== undefined) {
67821                     pendingNameIndex = nameIndex;
67822                     hasPendingName = true;
67823                 }
67824             }
67825             exit();
67826         }
67827         function appendSourceMap(generatedLine, generatedCharacter, map, sourceMapPath, start, end) {
67828             ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack");
67829             ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative");
67830             enter();
67831             var sourceIndexToNewSourceIndexMap = [];
67832             var nameIndexToNewNameIndexMap;
67833             var mappingIterator = decodeMappings(map.mappings);
67834             for (var iterResult = mappingIterator.next(); !iterResult.done; iterResult = mappingIterator.next()) {
67835                 var raw = iterResult.value;
67836                 if (end && (raw.generatedLine > end.line ||
67837                     (raw.generatedLine === end.line && raw.generatedCharacter > end.character))) {
67838                     break;
67839                 }
67840                 if (start && (raw.generatedLine < start.line ||
67841                     (start.line === raw.generatedLine && raw.generatedCharacter < start.character))) {
67842                     continue;
67843                 }
67844                 var newSourceIndex = void 0;
67845                 var newSourceLine = void 0;
67846                 var newSourceCharacter = void 0;
67847                 var newNameIndex = void 0;
67848                 if (raw.sourceIndex !== undefined) {
67849                     newSourceIndex = sourceIndexToNewSourceIndexMap[raw.sourceIndex];
67850                     if (newSourceIndex === undefined) {
67851                         var rawPath = map.sources[raw.sourceIndex];
67852                         var relativePath = map.sourceRoot ? ts.combinePaths(map.sourceRoot, rawPath) : rawPath;
67853                         var combinedPath = ts.combinePaths(ts.getDirectoryPath(sourceMapPath), relativePath);
67854                         sourceIndexToNewSourceIndexMap[raw.sourceIndex] = newSourceIndex = addSource(combinedPath);
67855                         if (map.sourcesContent && typeof map.sourcesContent[raw.sourceIndex] === "string") {
67856                             setSourceContent(newSourceIndex, map.sourcesContent[raw.sourceIndex]);
67857                         }
67858                     }
67859                     newSourceLine = raw.sourceLine;
67860                     newSourceCharacter = raw.sourceCharacter;
67861                     if (map.names && raw.nameIndex !== undefined) {
67862                         if (!nameIndexToNewNameIndexMap)
67863                             nameIndexToNewNameIndexMap = [];
67864                         newNameIndex = nameIndexToNewNameIndexMap[raw.nameIndex];
67865                         if (newNameIndex === undefined) {
67866                             nameIndexToNewNameIndexMap[raw.nameIndex] = newNameIndex = addName(map.names[raw.nameIndex]);
67867                         }
67868                     }
67869                 }
67870                 var rawGeneratedLine = raw.generatedLine - (start ? start.line : 0);
67871                 var newGeneratedLine = rawGeneratedLine + generatedLine;
67872                 var rawGeneratedCharacter = start && start.line === raw.generatedLine ? raw.generatedCharacter - start.character : raw.generatedCharacter;
67873                 var newGeneratedCharacter = rawGeneratedLine === 0 ? rawGeneratedCharacter + generatedCharacter : rawGeneratedCharacter;
67874                 addMapping(newGeneratedLine, newGeneratedCharacter, newSourceIndex, newSourceLine, newSourceCharacter, newNameIndex);
67875             }
67876             exit();
67877         }
67878         function shouldCommitMapping() {
67879             return !hasLast
67880                 || lastGeneratedLine !== pendingGeneratedLine
67881                 || lastGeneratedCharacter !== pendingGeneratedCharacter
67882                 || lastSourceIndex !== pendingSourceIndex
67883                 || lastSourceLine !== pendingSourceLine
67884                 || lastSourceCharacter !== pendingSourceCharacter
67885                 || lastNameIndex !== pendingNameIndex;
67886         }
67887         function commitPendingMapping() {
67888             if (!hasPending || !shouldCommitMapping()) {
67889                 return;
67890             }
67891             enter();
67892             if (lastGeneratedLine < pendingGeneratedLine) {
67893                 do {
67894                     mappings += ";";
67895                     lastGeneratedLine++;
67896                     lastGeneratedCharacter = 0;
67897                 } while (lastGeneratedLine < pendingGeneratedLine);
67898             }
67899             else {
67900                 ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack");
67901                 if (hasLast) {
67902                     mappings += ",";
67903                 }
67904             }
67905             mappings += base64VLQFormatEncode(pendingGeneratedCharacter - lastGeneratedCharacter);
67906             lastGeneratedCharacter = pendingGeneratedCharacter;
67907             if (hasPendingSource) {
67908                 mappings += base64VLQFormatEncode(pendingSourceIndex - lastSourceIndex);
67909                 lastSourceIndex = pendingSourceIndex;
67910                 mappings += base64VLQFormatEncode(pendingSourceLine - lastSourceLine);
67911                 lastSourceLine = pendingSourceLine;
67912                 mappings += base64VLQFormatEncode(pendingSourceCharacter - lastSourceCharacter);
67913                 lastSourceCharacter = pendingSourceCharacter;
67914                 if (hasPendingName) {
67915                     mappings += base64VLQFormatEncode(pendingNameIndex - lastNameIndex);
67916                     lastNameIndex = pendingNameIndex;
67917                 }
67918             }
67919             hasLast = true;
67920             exit();
67921         }
67922         function toJSON() {
67923             commitPendingMapping();
67924             return {
67925                 version: 3,
67926                 file: file,
67927                 sourceRoot: sourceRoot,
67928                 sources: sources,
67929                 names: names,
67930                 mappings: mappings,
67931                 sourcesContent: sourcesContent,
67932             };
67933         }
67934     }
67935     ts.createSourceMapGenerator = createSourceMapGenerator;
67936     var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/;
67937     var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/;
67938     function getLineInfo(text, lineStarts) {
67939         return {
67940             getLineCount: function () { return lineStarts.length; },
67941             getLineText: function (line) { return text.substring(lineStarts[line], lineStarts[line + 1]); }
67942         };
67943     }
67944     ts.getLineInfo = getLineInfo;
67945     function tryGetSourceMappingURL(lineInfo) {
67946         for (var index = lineInfo.getLineCount() - 1; index >= 0; index--) {
67947             var line = lineInfo.getLineText(index);
67948             var comment = sourceMapCommentRegExp.exec(line);
67949             if (comment) {
67950                 return comment[1];
67951             }
67952             else if (!line.match(whitespaceOrMapCommentRegExp)) {
67953                 break;
67954             }
67955         }
67956     }
67957     ts.tryGetSourceMappingURL = tryGetSourceMappingURL;
67958     function isStringOrNull(x) {
67959         return typeof x === "string" || x === null;
67960     }
67961     function isRawSourceMap(x) {
67962         return x !== null
67963             && typeof x === "object"
67964             && x.version === 3
67965             && typeof x.file === "string"
67966             && typeof x.mappings === "string"
67967             && ts.isArray(x.sources) && ts.every(x.sources, ts.isString)
67968             && (x.sourceRoot === undefined || x.sourceRoot === null || typeof x.sourceRoot === "string")
67969             && (x.sourcesContent === undefined || x.sourcesContent === null || ts.isArray(x.sourcesContent) && ts.every(x.sourcesContent, isStringOrNull))
67970             && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString));
67971     }
67972     ts.isRawSourceMap = isRawSourceMap;
67973     function tryParseRawSourceMap(text) {
67974         try {
67975             var parsed = JSON.parse(text);
67976             if (isRawSourceMap(parsed)) {
67977                 return parsed;
67978             }
67979         }
67980         catch (_a) {
67981         }
67982         return undefined;
67983     }
67984     ts.tryParseRawSourceMap = tryParseRawSourceMap;
67985     function decodeMappings(mappings) {
67986         var done = false;
67987         var pos = 0;
67988         var generatedLine = 0;
67989         var generatedCharacter = 0;
67990         var sourceIndex = 0;
67991         var sourceLine = 0;
67992         var sourceCharacter = 0;
67993         var nameIndex = 0;
67994         var error;
67995         return {
67996             get pos() { return pos; },
67997             get error() { return error; },
67998             get state() { return captureMapping(true, true); },
67999             next: function () {
68000                 while (!done && pos < mappings.length) {
68001                     var ch = mappings.charCodeAt(pos);
68002                     if (ch === 59) {
68003                         generatedLine++;
68004                         generatedCharacter = 0;
68005                         pos++;
68006                         continue;
68007                     }
68008                     if (ch === 44) {
68009                         pos++;
68010                         continue;
68011                     }
68012                     var hasSource = false;
68013                     var hasName = false;
68014                     generatedCharacter += base64VLQFormatDecode();
68015                     if (hasReportedError())
68016                         return stopIterating();
68017                     if (generatedCharacter < 0)
68018                         return setErrorAndStopIterating("Invalid generatedCharacter found");
68019                     if (!isSourceMappingSegmentEnd()) {
68020                         hasSource = true;
68021                         sourceIndex += base64VLQFormatDecode();
68022                         if (hasReportedError())
68023                             return stopIterating();
68024                         if (sourceIndex < 0)
68025                             return setErrorAndStopIterating("Invalid sourceIndex found");
68026                         if (isSourceMappingSegmentEnd())
68027                             return setErrorAndStopIterating("Unsupported Format: No entries after sourceIndex");
68028                         sourceLine += base64VLQFormatDecode();
68029                         if (hasReportedError())
68030                             return stopIterating();
68031                         if (sourceLine < 0)
68032                             return setErrorAndStopIterating("Invalid sourceLine found");
68033                         if (isSourceMappingSegmentEnd())
68034                             return setErrorAndStopIterating("Unsupported Format: No entries after sourceLine");
68035                         sourceCharacter += base64VLQFormatDecode();
68036                         if (hasReportedError())
68037                             return stopIterating();
68038                         if (sourceCharacter < 0)
68039                             return setErrorAndStopIterating("Invalid sourceCharacter found");
68040                         if (!isSourceMappingSegmentEnd()) {
68041                             hasName = true;
68042                             nameIndex += base64VLQFormatDecode();
68043                             if (hasReportedError())
68044                                 return stopIterating();
68045                             if (nameIndex < 0)
68046                                 return setErrorAndStopIterating("Invalid nameIndex found");
68047                             if (!isSourceMappingSegmentEnd())
68048                                 return setErrorAndStopIterating("Unsupported Error Format: Entries after nameIndex");
68049                         }
68050                     }
68051                     return { value: captureMapping(hasSource, hasName), done: done };
68052                 }
68053                 return stopIterating();
68054             }
68055         };
68056         function captureMapping(hasSource, hasName) {
68057             return {
68058                 generatedLine: generatedLine,
68059                 generatedCharacter: generatedCharacter,
68060                 sourceIndex: hasSource ? sourceIndex : undefined,
68061                 sourceLine: hasSource ? sourceLine : undefined,
68062                 sourceCharacter: hasSource ? sourceCharacter : undefined,
68063                 nameIndex: hasName ? nameIndex : undefined
68064             };
68065         }
68066         function stopIterating() {
68067             done = true;
68068             return { value: undefined, done: true };
68069         }
68070         function setError(message) {
68071             if (error === undefined) {
68072                 error = message;
68073             }
68074         }
68075         function setErrorAndStopIterating(message) {
68076             setError(message);
68077             return stopIterating();
68078         }
68079         function hasReportedError() {
68080             return error !== undefined;
68081         }
68082         function isSourceMappingSegmentEnd() {
68083             return (pos === mappings.length ||
68084                 mappings.charCodeAt(pos) === 44 ||
68085                 mappings.charCodeAt(pos) === 59);
68086         }
68087         function base64VLQFormatDecode() {
68088             var moreDigits = true;
68089             var shiftCount = 0;
68090             var value = 0;
68091             for (; moreDigits; pos++) {
68092                 if (pos >= mappings.length)
68093                     return setError("Error in decoding base64VLQFormatDecode, past the mapping string"), -1;
68094                 var currentByte = base64FormatDecode(mappings.charCodeAt(pos));
68095                 if (currentByte === -1)
68096                     return setError("Invalid character in VLQ"), -1;
68097                 moreDigits = (currentByte & 32) !== 0;
68098                 value = value | ((currentByte & 31) << shiftCount);
68099                 shiftCount += 5;
68100             }
68101             if ((value & 1) === 0) {
68102                 value = value >> 1;
68103             }
68104             else {
68105                 value = value >> 1;
68106                 value = -value;
68107             }
68108             return value;
68109         }
68110     }
68111     ts.decodeMappings = decodeMappings;
68112     function sameMapping(left, right) {
68113         return left === right
68114             || left.generatedLine === right.generatedLine
68115                 && left.generatedCharacter === right.generatedCharacter
68116                 && left.sourceIndex === right.sourceIndex
68117                 && left.sourceLine === right.sourceLine
68118                 && left.sourceCharacter === right.sourceCharacter
68119                 && left.nameIndex === right.nameIndex;
68120     }
68121     ts.sameMapping = sameMapping;
68122     function isSourceMapping(mapping) {
68123         return mapping.sourceIndex !== undefined
68124             && mapping.sourceLine !== undefined
68125             && mapping.sourceCharacter !== undefined;
68126     }
68127     ts.isSourceMapping = isSourceMapping;
68128     function base64FormatEncode(value) {
68129         return value >= 0 && value < 26 ? 65 + value :
68130             value >= 26 && value < 52 ? 97 + value - 26 :
68131                 value >= 52 && value < 62 ? 48 + value - 52 :
68132                     value === 62 ? 43 :
68133                         value === 63 ? 47 :
68134                             ts.Debug.fail(value + ": not a base64 value");
68135     }
68136     function base64FormatDecode(ch) {
68137         return ch >= 65 && ch <= 90 ? ch - 65 :
68138             ch >= 97 && ch <= 122 ? ch - 97 + 26 :
68139                 ch >= 48 && ch <= 57 ? ch - 48 + 52 :
68140                     ch === 43 ? 62 :
68141                         ch === 47 ? 63 :
68142                             -1;
68143     }
68144     function base64VLQFormatEncode(inValue) {
68145         if (inValue < 0) {
68146             inValue = ((-inValue) << 1) + 1;
68147         }
68148         else {
68149             inValue = inValue << 1;
68150         }
68151         var encodedStr = "";
68152         do {
68153             var currentDigit = inValue & 31;
68154             inValue = inValue >> 5;
68155             if (inValue > 0) {
68156                 currentDigit = currentDigit | 32;
68157             }
68158             encodedStr = encodedStr + String.fromCharCode(base64FormatEncode(currentDigit));
68159         } while (inValue > 0);
68160         return encodedStr;
68161     }
68162     function isSourceMappedPosition(value) {
68163         return value.sourceIndex !== undefined
68164             && value.sourcePosition !== undefined;
68165     }
68166     function sameMappedPosition(left, right) {
68167         return left.generatedPosition === right.generatedPosition
68168             && left.sourceIndex === right.sourceIndex
68169             && left.sourcePosition === right.sourcePosition;
68170     }
68171     function compareSourcePositions(left, right) {
68172         ts.Debug.assert(left.sourceIndex === right.sourceIndex);
68173         return ts.compareValues(left.sourcePosition, right.sourcePosition);
68174     }
68175     function compareGeneratedPositions(left, right) {
68176         return ts.compareValues(left.generatedPosition, right.generatedPosition);
68177     }
68178     function getSourcePositionOfMapping(value) {
68179         return value.sourcePosition;
68180     }
68181     function getGeneratedPositionOfMapping(value) {
68182         return value.generatedPosition;
68183     }
68184     function createDocumentPositionMapper(host, map, mapPath) {
68185         var mapDirectory = ts.getDirectoryPath(mapPath);
68186         var sourceRoot = map.sourceRoot ? ts.getNormalizedAbsolutePath(map.sourceRoot, mapDirectory) : mapDirectory;
68187         var generatedAbsoluteFilePath = ts.getNormalizedAbsolutePath(map.file, mapDirectory);
68188         var generatedFile = host.getSourceFileLike(generatedAbsoluteFilePath);
68189         var sourceFileAbsolutePaths = map.sources.map(function (source) { return ts.getNormalizedAbsolutePath(source, sourceRoot); });
68190         var sourceToSourceIndexMap = new ts.Map(sourceFileAbsolutePaths.map(function (source, i) { return [host.getCanonicalFileName(source), i]; }));
68191         var decodedMappings;
68192         var generatedMappings;
68193         var sourceMappings;
68194         return {
68195             getSourcePosition: getSourcePosition,
68196             getGeneratedPosition: getGeneratedPosition
68197         };
68198         function processMapping(mapping) {
68199             var generatedPosition = generatedFile !== undefined
68200                 ? ts.getPositionOfLineAndCharacter(generatedFile, mapping.generatedLine, mapping.generatedCharacter, true)
68201                 : -1;
68202             var source;
68203             var sourcePosition;
68204             if (isSourceMapping(mapping)) {
68205                 var sourceFile = host.getSourceFileLike(sourceFileAbsolutePaths[mapping.sourceIndex]);
68206                 source = map.sources[mapping.sourceIndex];
68207                 sourcePosition = sourceFile !== undefined
68208                     ? ts.getPositionOfLineAndCharacter(sourceFile, mapping.sourceLine, mapping.sourceCharacter, true)
68209                     : -1;
68210             }
68211             return {
68212                 generatedPosition: generatedPosition,
68213                 source: source,
68214                 sourceIndex: mapping.sourceIndex,
68215                 sourcePosition: sourcePosition,
68216                 nameIndex: mapping.nameIndex
68217             };
68218         }
68219         function getDecodedMappings() {
68220             if (decodedMappings === undefined) {
68221                 var decoder = decodeMappings(map.mappings);
68222                 var mappings = ts.arrayFrom(decoder, processMapping);
68223                 if (decoder.error !== undefined) {
68224                     if (host.log) {
68225                         host.log("Encountered error while decoding sourcemap: " + decoder.error);
68226                     }
68227                     decodedMappings = ts.emptyArray;
68228                 }
68229                 else {
68230                     decodedMappings = mappings;
68231                 }
68232             }
68233             return decodedMappings;
68234         }
68235         function getSourceMappings(sourceIndex) {
68236             if (sourceMappings === undefined) {
68237                 var lists = [];
68238                 for (var _i = 0, _a = getDecodedMappings(); _i < _a.length; _i++) {
68239                     var mapping = _a[_i];
68240                     if (!isSourceMappedPosition(mapping))
68241                         continue;
68242                     var list = lists[mapping.sourceIndex];
68243                     if (!list)
68244                         lists[mapping.sourceIndex] = list = [];
68245                     list.push(mapping);
68246                 }
68247                 sourceMappings = lists.map(function (list) { return ts.sortAndDeduplicate(list, compareSourcePositions, sameMappedPosition); });
68248             }
68249             return sourceMappings[sourceIndex];
68250         }
68251         function getGeneratedMappings() {
68252             if (generatedMappings === undefined) {
68253                 var list = [];
68254                 for (var _i = 0, _a = getDecodedMappings(); _i < _a.length; _i++) {
68255                     var mapping = _a[_i];
68256                     list.push(mapping);
68257                 }
68258                 generatedMappings = ts.sortAndDeduplicate(list, compareGeneratedPositions, sameMappedPosition);
68259             }
68260             return generatedMappings;
68261         }
68262         function getGeneratedPosition(loc) {
68263             var sourceIndex = sourceToSourceIndexMap.get(host.getCanonicalFileName(loc.fileName));
68264             if (sourceIndex === undefined)
68265                 return loc;
68266             var sourceMappings = getSourceMappings(sourceIndex);
68267             if (!ts.some(sourceMappings))
68268                 return loc;
68269             var targetIndex = ts.binarySearchKey(sourceMappings, loc.pos, getSourcePositionOfMapping, ts.compareValues);
68270             if (targetIndex < 0) {
68271                 targetIndex = ~targetIndex;
68272             }
68273             var mapping = sourceMappings[targetIndex];
68274             if (mapping === undefined || mapping.sourceIndex !== sourceIndex) {
68275                 return loc;
68276             }
68277             return { fileName: generatedAbsoluteFilePath, pos: mapping.generatedPosition };
68278         }
68279         function getSourcePosition(loc) {
68280             var generatedMappings = getGeneratedMappings();
68281             if (!ts.some(generatedMappings))
68282                 return loc;
68283             var targetIndex = ts.binarySearchKey(generatedMappings, loc.pos, getGeneratedPositionOfMapping, ts.compareValues);
68284             if (targetIndex < 0) {
68285                 targetIndex = ~targetIndex;
68286             }
68287             var mapping = generatedMappings[targetIndex];
68288             if (mapping === undefined || !isSourceMappedPosition(mapping)) {
68289                 return loc;
68290             }
68291             return { fileName: sourceFileAbsolutePaths[mapping.sourceIndex], pos: mapping.sourcePosition };
68292         }
68293     }
68294     ts.createDocumentPositionMapper = createDocumentPositionMapper;
68295     ts.identitySourceMapConsumer = {
68296         getSourcePosition: ts.identity,
68297         getGeneratedPosition: ts.identity
68298     };
68299 })(ts || (ts = {}));
68300 var ts;
68301 (function (ts) {
68302     function getOriginalNodeId(node) {
68303         node = ts.getOriginalNode(node);
68304         return node ? ts.getNodeId(node) : 0;
68305     }
68306     ts.getOriginalNodeId = getOriginalNodeId;
68307     function containsDefaultReference(node) {
68308         if (!node)
68309             return false;
68310         if (!ts.isNamedImports(node))
68311             return false;
68312         return ts.some(node.elements, isNamedDefaultReference);
68313     }
68314     function isNamedDefaultReference(e) {
68315         return e.propertyName !== undefined && e.propertyName.escapedText === "default";
68316     }
68317     function chainBundle(context, transformSourceFile) {
68318         return transformSourceFileOrBundle;
68319         function transformSourceFileOrBundle(node) {
68320             return node.kind === 297 ? transformSourceFile(node) : transformBundle(node);
68321         }
68322         function transformBundle(node) {
68323             return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends);
68324         }
68325     }
68326     ts.chainBundle = chainBundle;
68327     function getExportNeedsImportStarHelper(node) {
68328         return !!ts.getNamespaceDeclarationNode(node);
68329     }
68330     ts.getExportNeedsImportStarHelper = getExportNeedsImportStarHelper;
68331     function getImportNeedsImportStarHelper(node) {
68332         if (!!ts.getNamespaceDeclarationNode(node)) {
68333             return true;
68334         }
68335         var bindings = node.importClause && node.importClause.namedBindings;
68336         if (!bindings) {
68337             return false;
68338         }
68339         if (!ts.isNamedImports(bindings))
68340             return false;
68341         var defaultRefCount = 0;
68342         for (var _i = 0, _a = bindings.elements; _i < _a.length; _i++) {
68343             var binding = _a[_i];
68344             if (isNamedDefaultReference(binding)) {
68345                 defaultRefCount++;
68346             }
68347         }
68348         return (defaultRefCount > 0 && defaultRefCount !== bindings.elements.length) || (!!(bindings.elements.length - defaultRefCount) && ts.isDefaultImport(node));
68349     }
68350     ts.getImportNeedsImportStarHelper = getImportNeedsImportStarHelper;
68351     function getImportNeedsImportDefaultHelper(node) {
68352         return !getImportNeedsImportStarHelper(node) && (ts.isDefaultImport(node) || (!!node.importClause && ts.isNamedImports(node.importClause.namedBindings) && containsDefaultReference(node.importClause.namedBindings)));
68353     }
68354     ts.getImportNeedsImportDefaultHelper = getImportNeedsImportDefaultHelper;
68355     function collectExternalModuleInfo(context, sourceFile, resolver, compilerOptions) {
68356         var externalImports = [];
68357         var exportSpecifiers = ts.createMultiMap();
68358         var exportedBindings = [];
68359         var uniqueExports = new ts.Map();
68360         var exportedNames;
68361         var hasExportDefault = false;
68362         var exportEquals;
68363         var hasExportStarsToExportValues = false;
68364         var hasImportStar = false;
68365         var hasImportDefault = false;
68366         for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
68367             var node = _a[_i];
68368             switch (node.kind) {
68369                 case 261:
68370                     externalImports.push(node);
68371                     if (!hasImportStar && getImportNeedsImportStarHelper(node)) {
68372                         hasImportStar = true;
68373                     }
68374                     if (!hasImportDefault && getImportNeedsImportDefaultHelper(node)) {
68375                         hasImportDefault = true;
68376                     }
68377                     break;
68378                 case 260:
68379                     if (node.moduleReference.kind === 272) {
68380                         externalImports.push(node);
68381                     }
68382                     break;
68383                 case 267:
68384                     if (node.moduleSpecifier) {
68385                         if (!node.exportClause) {
68386                             externalImports.push(node);
68387                             hasExportStarsToExportValues = true;
68388                         }
68389                         else {
68390                             externalImports.push(node);
68391                             if (ts.isNamedExports(node.exportClause)) {
68392                                 addExportedNamesForExportDeclaration(node);
68393                             }
68394                             else {
68395                                 var name = node.exportClause.name;
68396                                 if (!uniqueExports.get(ts.idText(name))) {
68397                                     multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
68398                                     uniqueExports.set(ts.idText(name), true);
68399                                     exportedNames = ts.append(exportedNames, name);
68400                                 }
68401                                 hasImportStar = true;
68402                             }
68403                         }
68404                     }
68405                     else {
68406                         addExportedNamesForExportDeclaration(node);
68407                     }
68408                     break;
68409                 case 266:
68410                     if (node.isExportEquals && !exportEquals) {
68411                         exportEquals = node;
68412                     }
68413                     break;
68414                 case 232:
68415                     if (ts.hasSyntacticModifier(node, 1)) {
68416                         for (var _b = 0, _c = node.declarationList.declarations; _b < _c.length; _b++) {
68417                             var decl = _c[_b];
68418                             exportedNames = collectExportedVariableInfo(decl, uniqueExports, exportedNames);
68419                         }
68420                     }
68421                     break;
68422                 case 251:
68423                     if (ts.hasSyntacticModifier(node, 1)) {
68424                         if (ts.hasSyntacticModifier(node, 512)) {
68425                             if (!hasExportDefault) {
68426                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node));
68427                                 hasExportDefault = true;
68428                             }
68429                         }
68430                         else {
68431                             var name = node.name;
68432                             if (!uniqueExports.get(ts.idText(name))) {
68433                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
68434                                 uniqueExports.set(ts.idText(name), true);
68435                                 exportedNames = ts.append(exportedNames, name);
68436                             }
68437                         }
68438                     }
68439                     break;
68440                 case 252:
68441                     if (ts.hasSyntacticModifier(node, 1)) {
68442                         if (ts.hasSyntacticModifier(node, 512)) {
68443                             if (!hasExportDefault) {
68444                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node));
68445                                 hasExportDefault = true;
68446                             }
68447                         }
68448                         else {
68449                             var name = node.name;
68450                             if (name && !uniqueExports.get(ts.idText(name))) {
68451                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
68452                                 uniqueExports.set(ts.idText(name), true);
68453                                 exportedNames = ts.append(exportedNames, name);
68454                             }
68455                         }
68456                     }
68457                     break;
68458             }
68459         }
68460         var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(context.factory, context.getEmitHelperFactory(), sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault);
68461         if (externalHelpersImportDeclaration) {
68462             externalImports.unshift(externalHelpersImportDeclaration);
68463         }
68464         return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames, externalHelpersImportDeclaration: externalHelpersImportDeclaration };
68465         function addExportedNamesForExportDeclaration(node) {
68466             for (var _i = 0, _a = ts.cast(node.exportClause, ts.isNamedExports).elements; _i < _a.length; _i++) {
68467                 var specifier = _a[_i];
68468                 if (!uniqueExports.get(ts.idText(specifier.name))) {
68469                     var name = specifier.propertyName || specifier.name;
68470                     if (!node.moduleSpecifier) {
68471                         exportSpecifiers.add(ts.idText(name), specifier);
68472                     }
68473                     var decl = resolver.getReferencedImportDeclaration(name)
68474                         || resolver.getReferencedValueDeclaration(name);
68475                     if (decl) {
68476                         multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name);
68477                     }
68478                     uniqueExports.set(ts.idText(specifier.name), true);
68479                     exportedNames = ts.append(exportedNames, specifier.name);
68480                 }
68481             }
68482         }
68483     }
68484     ts.collectExternalModuleInfo = collectExternalModuleInfo;
68485     function collectExportedVariableInfo(decl, uniqueExports, exportedNames) {
68486         if (ts.isBindingPattern(decl.name)) {
68487             for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) {
68488                 var element = _a[_i];
68489                 if (!ts.isOmittedExpression(element)) {
68490                     exportedNames = collectExportedVariableInfo(element, uniqueExports, exportedNames);
68491                 }
68492             }
68493         }
68494         else if (!ts.isGeneratedIdentifier(decl.name)) {
68495             var text = ts.idText(decl.name);
68496             if (!uniqueExports.get(text)) {
68497                 uniqueExports.set(text, true);
68498                 exportedNames = ts.append(exportedNames, decl.name);
68499             }
68500         }
68501         return exportedNames;
68502     }
68503     function multiMapSparseArrayAdd(map, key, value) {
68504         var values = map[key];
68505         if (values) {
68506             values.push(value);
68507         }
68508         else {
68509             map[key] = values = [value];
68510         }
68511         return values;
68512     }
68513     function isSimpleCopiableExpression(expression) {
68514         return ts.isStringLiteralLike(expression) ||
68515             expression.kind === 8 ||
68516             ts.isKeyword(expression.kind) ||
68517             ts.isIdentifier(expression);
68518     }
68519     ts.isSimpleCopiableExpression = isSimpleCopiableExpression;
68520     function isSimpleInlineableExpression(expression) {
68521         return !ts.isIdentifier(expression) && isSimpleCopiableExpression(expression) ||
68522             ts.isWellKnownSymbolSyntactically(expression);
68523     }
68524     ts.isSimpleInlineableExpression = isSimpleInlineableExpression;
68525     function isCompoundAssignment(kind) {
68526         return kind >= 63
68527             && kind <= 77;
68528     }
68529     ts.isCompoundAssignment = isCompoundAssignment;
68530     function getNonAssignmentOperatorForCompoundAssignment(kind) {
68531         switch (kind) {
68532             case 63: return 39;
68533             case 64: return 40;
68534             case 65: return 41;
68535             case 66: return 42;
68536             case 67: return 43;
68537             case 68: return 44;
68538             case 69: return 47;
68539             case 70: return 48;
68540             case 71: return 49;
68541             case 72: return 50;
68542             case 73: return 51;
68543             case 77: return 52;
68544             case 74: return 56;
68545             case 75: return 55;
68546             case 76: return 60;
68547         }
68548     }
68549     ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment;
68550     function addPrologueDirectivesAndInitialSuperCall(factory, ctor, result, visitor) {
68551         if (ctor.body) {
68552             var statements = ctor.body.statements;
68553             var index = factory.copyPrologue(statements, result, false, visitor);
68554             if (index === statements.length) {
68555                 return index;
68556             }
68557             var superIndex = ts.findIndex(statements, function (s) { return ts.isExpressionStatement(s) && ts.isSuperCall(s.expression); }, index);
68558             if (superIndex > -1) {
68559                 for (var i = index; i <= superIndex; i++) {
68560                     result.push(ts.visitNode(statements[i], visitor, ts.isStatement));
68561                 }
68562                 return superIndex + 1;
68563             }
68564             return index;
68565         }
68566         return 0;
68567     }
68568     ts.addPrologueDirectivesAndInitialSuperCall = addPrologueDirectivesAndInitialSuperCall;
68569     function getProperties(node, requireInitializer, isStatic) {
68570         return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); });
68571     }
68572     ts.getProperties = getProperties;
68573     function isInitializedOrStaticProperty(member, requireInitializer, isStatic) {
68574         return ts.isPropertyDeclaration(member)
68575             && (!!member.initializer || !requireInitializer)
68576             && ts.hasStaticModifier(member) === isStatic;
68577     }
68578     function isInitializedProperty(member) {
68579         return member.kind === 163
68580             && member.initializer !== undefined;
68581     }
68582     ts.isInitializedProperty = isInitializedProperty;
68583 })(ts || (ts = {}));
68584 var ts;
68585 (function (ts) {
68586     function flattenDestructuringAssignment(node, visitor, context, level, needsValue, createAssignmentCallback) {
68587         var location = node;
68588         var value;
68589         if (ts.isDestructuringAssignment(node)) {
68590             value = node.right;
68591             while (ts.isEmptyArrayLiteral(node.left) || ts.isEmptyObjectLiteral(node.left)) {
68592                 if (ts.isDestructuringAssignment(value)) {
68593                     location = node = value;
68594                     value = node.right;
68595                 }
68596                 else {
68597                     return ts.visitNode(value, visitor, ts.isExpression);
68598                 }
68599             }
68600         }
68601         var expressions;
68602         var flattenContext = {
68603             context: context,
68604             level: level,
68605             downlevelIteration: !!context.getCompilerOptions().downlevelIteration,
68606             hoistTempVariables: true,
68607             emitExpression: emitExpression,
68608             emitBindingOrAssignment: emitBindingOrAssignment,
68609             createArrayBindingOrAssignmentPattern: function (elements) { return makeArrayAssignmentPattern(context.factory, elements); },
68610             createObjectBindingOrAssignmentPattern: function (elements) { return makeObjectAssignmentPattern(context.factory, elements); },
68611             createArrayBindingOrAssignmentElement: makeAssignmentElement,
68612             visitor: visitor
68613         };
68614         if (value) {
68615             value = ts.visitNode(value, visitor, ts.isExpression);
68616             if (ts.isIdentifier(value) && bindingOrAssignmentElementAssignsToName(node, value.escapedText) ||
68617                 bindingOrAssignmentElementContainsNonLiteralComputedName(node)) {
68618                 value = ensureIdentifier(flattenContext, value, false, location);
68619             }
68620             else if (needsValue) {
68621                 value = ensureIdentifier(flattenContext, value, true, location);
68622             }
68623             else if (ts.nodeIsSynthesized(node)) {
68624                 location = value;
68625             }
68626         }
68627         flattenBindingOrAssignmentElement(flattenContext, node, value, location, ts.isDestructuringAssignment(node));
68628         if (value && needsValue) {
68629             if (!ts.some(expressions)) {
68630                 return value;
68631             }
68632             expressions.push(value);
68633         }
68634         return context.factory.inlineExpressions(expressions) || context.factory.createOmittedExpression();
68635         function emitExpression(expression) {
68636             expressions = ts.append(expressions, expression);
68637         }
68638         function emitBindingOrAssignment(target, value, location, original) {
68639             ts.Debug.assertNode(target, createAssignmentCallback ? ts.isIdentifier : ts.isExpression);
68640             var expression = createAssignmentCallback
68641                 ? createAssignmentCallback(target, value, location)
68642                 : ts.setTextRange(context.factory.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value), location);
68643             expression.original = original;
68644             emitExpression(expression);
68645         }
68646     }
68647     ts.flattenDestructuringAssignment = flattenDestructuringAssignment;
68648     function bindingOrAssignmentElementAssignsToName(element, escapedName) {
68649         var target = ts.getTargetOfBindingOrAssignmentElement(element);
68650         if (ts.isBindingOrAssignmentPattern(target)) {
68651             return bindingOrAssignmentPatternAssignsToName(target, escapedName);
68652         }
68653         else if (ts.isIdentifier(target)) {
68654             return target.escapedText === escapedName;
68655         }
68656         return false;
68657     }
68658     function bindingOrAssignmentPatternAssignsToName(pattern, escapedName) {
68659         var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern);
68660         for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) {
68661             var element = elements_3[_i];
68662             if (bindingOrAssignmentElementAssignsToName(element, escapedName)) {
68663                 return true;
68664             }
68665         }
68666         return false;
68667     }
68668     function bindingOrAssignmentElementContainsNonLiteralComputedName(element) {
68669         var propertyName = ts.tryGetPropertyNameOfBindingOrAssignmentElement(element);
68670         if (propertyName && ts.isComputedPropertyName(propertyName) && !ts.isLiteralExpression(propertyName.expression)) {
68671             return true;
68672         }
68673         var target = ts.getTargetOfBindingOrAssignmentElement(element);
68674         return !!target && ts.isBindingOrAssignmentPattern(target) && bindingOrAssignmentPatternContainsNonLiteralComputedName(target);
68675     }
68676     function bindingOrAssignmentPatternContainsNonLiteralComputedName(pattern) {
68677         return !!ts.forEach(ts.getElementsOfBindingOrAssignmentPattern(pattern), bindingOrAssignmentElementContainsNonLiteralComputedName);
68678     }
68679     function flattenDestructuringBinding(node, visitor, context, level, rval, hoistTempVariables, skipInitializer) {
68680         if (hoistTempVariables === void 0) { hoistTempVariables = false; }
68681         var pendingExpressions;
68682         var pendingDeclarations = [];
68683         var declarations = [];
68684         var flattenContext = {
68685             context: context,
68686             level: level,
68687             downlevelIteration: !!context.getCompilerOptions().downlevelIteration,
68688             hoistTempVariables: hoistTempVariables,
68689             emitExpression: emitExpression,
68690             emitBindingOrAssignment: emitBindingOrAssignment,
68691             createArrayBindingOrAssignmentPattern: function (elements) { return makeArrayBindingPattern(context.factory, elements); },
68692             createObjectBindingOrAssignmentPattern: function (elements) { return makeObjectBindingPattern(context.factory, elements); },
68693             createArrayBindingOrAssignmentElement: function (name) { return makeBindingElement(context.factory, name); },
68694             visitor: visitor
68695         };
68696         if (ts.isVariableDeclaration(node)) {
68697             var initializer = ts.getInitializerOfBindingOrAssignmentElement(node);
68698             if (initializer && (ts.isIdentifier(initializer) && bindingOrAssignmentElementAssignsToName(node, initializer.escapedText) ||
68699                 bindingOrAssignmentElementContainsNonLiteralComputedName(node))) {
68700                 initializer = ensureIdentifier(flattenContext, initializer, false, initializer);
68701                 node = context.factory.updateVariableDeclaration(node, node.name, undefined, undefined, initializer);
68702             }
68703         }
68704         flattenBindingOrAssignmentElement(flattenContext, node, rval, node, skipInitializer);
68705         if (pendingExpressions) {
68706             var temp = context.factory.createTempVariable(undefined);
68707             if (hoistTempVariables) {
68708                 var value = context.factory.inlineExpressions(pendingExpressions);
68709                 pendingExpressions = undefined;
68710                 emitBindingOrAssignment(temp, value, undefined, undefined);
68711             }
68712             else {
68713                 context.hoistVariableDeclaration(temp);
68714                 var pendingDeclaration = ts.last(pendingDeclarations);
68715                 pendingDeclaration.pendingExpressions = ts.append(pendingDeclaration.pendingExpressions, context.factory.createAssignment(temp, pendingDeclaration.value));
68716                 ts.addRange(pendingDeclaration.pendingExpressions, pendingExpressions);
68717                 pendingDeclaration.value = temp;
68718             }
68719         }
68720         for (var _i = 0, pendingDeclarations_1 = pendingDeclarations; _i < pendingDeclarations_1.length; _i++) {
68721             var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name = _a.name, value = _a.value, location = _a.location, original = _a.original;
68722             var variable = context.factory.createVariableDeclaration(name, undefined, undefined, pendingExpressions_1 ? context.factory.inlineExpressions(ts.append(pendingExpressions_1, value)) : value);
68723             variable.original = original;
68724             ts.setTextRange(variable, location);
68725             declarations.push(variable);
68726         }
68727         return declarations;
68728         function emitExpression(value) {
68729             pendingExpressions = ts.append(pendingExpressions, value);
68730         }
68731         function emitBindingOrAssignment(target, value, location, original) {
68732             ts.Debug.assertNode(target, ts.isBindingName);
68733             if (pendingExpressions) {
68734                 value = context.factory.inlineExpressions(ts.append(pendingExpressions, value));
68735                 pendingExpressions = undefined;
68736             }
68737             pendingDeclarations.push({ pendingExpressions: pendingExpressions, name: target, value: value, location: location, original: original });
68738         }
68739     }
68740     ts.flattenDestructuringBinding = flattenDestructuringBinding;
68741     function flattenBindingOrAssignmentElement(flattenContext, element, value, location, skipInitializer) {
68742         var bindingTarget = ts.getTargetOfBindingOrAssignmentElement(element);
68743         if (!skipInitializer) {
68744             var initializer = ts.visitNode(ts.getInitializerOfBindingOrAssignmentElement(element), flattenContext.visitor, ts.isExpression);
68745             if (initializer) {
68746                 if (value) {
68747                     value = createDefaultValueCheck(flattenContext, value, initializer, location);
68748                     if (!ts.isSimpleInlineableExpression(initializer) && ts.isBindingOrAssignmentPattern(bindingTarget)) {
68749                         value = ensureIdentifier(flattenContext, value, true, location);
68750                     }
68751                 }
68752                 else {
68753                     value = initializer;
68754                 }
68755             }
68756             else if (!value) {
68757                 value = flattenContext.context.factory.createVoidZero();
68758             }
68759         }
68760         if (ts.isObjectBindingOrAssignmentPattern(bindingTarget)) {
68761             flattenObjectBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location);
68762         }
68763         else if (ts.isArrayBindingOrAssignmentPattern(bindingTarget)) {
68764             flattenArrayBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location);
68765         }
68766         else {
68767             flattenContext.emitBindingOrAssignment(bindingTarget, value, location, element);
68768         }
68769     }
68770     function flattenObjectBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) {
68771         var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern);
68772         var numElements = elements.length;
68773         if (numElements !== 1) {
68774             var reuseIdentifierExpressions = !ts.isDeclarationBindingElement(parent) || numElements !== 0;
68775             value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location);
68776         }
68777         var bindingElements;
68778         var computedTempVariables;
68779         for (var i = 0; i < numElements; i++) {
68780             var element = elements[i];
68781             if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) {
68782                 var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element);
68783                 if (flattenContext.level >= 1
68784                     && !(element.transformFlags & (8192 | 16384))
68785                     && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (8192 | 16384))
68786                     && !ts.isComputedPropertyName(propertyName)) {
68787                     bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor));
68788                 }
68789                 else {
68790                     if (bindingElements) {
68791                         flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
68792                         bindingElements = undefined;
68793                     }
68794                     var rhsValue = createDestructuringPropertyAccess(flattenContext, value, propertyName);
68795                     if (ts.isComputedPropertyName(propertyName)) {
68796                         computedTempVariables = ts.append(computedTempVariables, rhsValue.argumentExpression);
68797                     }
68798                     flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
68799                 }
68800             }
68801             else if (i === numElements - 1) {
68802                 if (bindingElements) {
68803                     flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
68804                     bindingElements = undefined;
68805                 }
68806                 var rhsValue = flattenContext.context.getEmitHelperFactory().createRestHelper(value, elements, computedTempVariables, pattern);
68807                 flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
68808             }
68809         }
68810         if (bindingElements) {
68811             flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
68812         }
68813     }
68814     function flattenArrayBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) {
68815         var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern);
68816         var numElements = elements.length;
68817         if (flattenContext.level < 1 && flattenContext.downlevelIteration) {
68818             value = ensureIdentifier(flattenContext, ts.setTextRange(flattenContext.context.getEmitHelperFactory().createReadHelper(value, numElements > 0 && ts.getRestIndicatorOfBindingOrAssignmentElement(elements[numElements - 1])
68819                 ? undefined
68820                 : numElements), location), false, location);
68821         }
68822         else if (numElements !== 1 && (flattenContext.level < 1 || numElements === 0)
68823             || ts.every(elements, ts.isOmittedExpression)) {
68824             var reuseIdentifierExpressions = !ts.isDeclarationBindingElement(parent) || numElements !== 0;
68825             value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location);
68826         }
68827         var bindingElements;
68828         var restContainingElements;
68829         for (var i = 0; i < numElements; i++) {
68830             var element = elements[i];
68831             if (flattenContext.level >= 1) {
68832                 if (element.transformFlags & 16384 || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) {
68833                     flattenContext.hasTransformedPriorElement = true;
68834                     var temp = flattenContext.context.factory.createTempVariable(undefined);
68835                     if (flattenContext.hoistTempVariables) {
68836                         flattenContext.context.hoistVariableDeclaration(temp);
68837                     }
68838                     restContainingElements = ts.append(restContainingElements, [temp, element]);
68839                     bindingElements = ts.append(bindingElements, flattenContext.createArrayBindingOrAssignmentElement(temp));
68840                 }
68841                 else {
68842                     bindingElements = ts.append(bindingElements, element);
68843                 }
68844             }
68845             else if (ts.isOmittedExpression(element)) {
68846                 continue;
68847             }
68848             else if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) {
68849                 var rhsValue = flattenContext.context.factory.createElementAccessExpression(value, i);
68850                 flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
68851             }
68852             else if (i === numElements - 1) {
68853                 var rhsValue = flattenContext.context.factory.createArraySliceCall(value, i);
68854                 flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
68855             }
68856         }
68857         if (bindingElements) {
68858             flattenContext.emitBindingOrAssignment(flattenContext.createArrayBindingOrAssignmentPattern(bindingElements), value, location, pattern);
68859         }
68860         if (restContainingElements) {
68861             for (var _i = 0, restContainingElements_1 = restContainingElements; _i < restContainingElements_1.length; _i++) {
68862                 var _a = restContainingElements_1[_i], id = _a[0], element = _a[1];
68863                 flattenBindingOrAssignmentElement(flattenContext, element, id, element);
68864             }
68865         }
68866     }
68867     function isSimpleBindingOrAssignmentElement(element) {
68868         var target = ts.getTargetOfBindingOrAssignmentElement(element);
68869         if (!target || ts.isOmittedExpression(target))
68870             return true;
68871         var propertyName = ts.tryGetPropertyNameOfBindingOrAssignmentElement(element);
68872         if (propertyName && !ts.isPropertyNameLiteral(propertyName))
68873             return false;
68874         var initializer = ts.getInitializerOfBindingOrAssignmentElement(element);
68875         if (initializer && !ts.isSimpleInlineableExpression(initializer))
68876             return false;
68877         if (ts.isBindingOrAssignmentPattern(target))
68878             return ts.every(ts.getElementsOfBindingOrAssignmentPattern(target), isSimpleBindingOrAssignmentElement);
68879         return ts.isIdentifier(target);
68880     }
68881     function createDefaultValueCheck(flattenContext, value, defaultValue, location) {
68882         value = ensureIdentifier(flattenContext, value, true, location);
68883         return flattenContext.context.factory.createConditionalExpression(flattenContext.context.factory.createTypeCheck(value, "undefined"), undefined, defaultValue, undefined, value);
68884     }
68885     function createDestructuringPropertyAccess(flattenContext, value, propertyName) {
68886         if (ts.isComputedPropertyName(propertyName)) {
68887             var argumentExpression = ensureIdentifier(flattenContext, ts.visitNode(propertyName.expression, flattenContext.visitor), false, propertyName);
68888             return flattenContext.context.factory.createElementAccessExpression(value, argumentExpression);
68889         }
68890         else if (ts.isStringOrNumericLiteralLike(propertyName)) {
68891             var argumentExpression = ts.factory.cloneNode(propertyName);
68892             return flattenContext.context.factory.createElementAccessExpression(value, argumentExpression);
68893         }
68894         else {
68895             var name = flattenContext.context.factory.createIdentifier(ts.idText(propertyName));
68896             return flattenContext.context.factory.createPropertyAccessExpression(value, name);
68897         }
68898     }
68899     function ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location) {
68900         if (ts.isIdentifier(value) && reuseIdentifierExpressions) {
68901             return value;
68902         }
68903         else {
68904             var temp = flattenContext.context.factory.createTempVariable(undefined);
68905             if (flattenContext.hoistTempVariables) {
68906                 flattenContext.context.hoistVariableDeclaration(temp);
68907                 flattenContext.emitExpression(ts.setTextRange(flattenContext.context.factory.createAssignment(temp, value), location));
68908             }
68909             else {
68910                 flattenContext.emitBindingOrAssignment(temp, value, location, undefined);
68911             }
68912             return temp;
68913         }
68914     }
68915     function makeArrayBindingPattern(factory, elements) {
68916         ts.Debug.assertEachNode(elements, ts.isArrayBindingElement);
68917         return factory.createArrayBindingPattern(elements);
68918     }
68919     function makeArrayAssignmentPattern(factory, elements) {
68920         return factory.createArrayLiteralExpression(ts.map(elements, factory.converters.convertToArrayAssignmentElement));
68921     }
68922     function makeObjectBindingPattern(factory, elements) {
68923         ts.Debug.assertEachNode(elements, ts.isBindingElement);
68924         return factory.createObjectBindingPattern(elements);
68925     }
68926     function makeObjectAssignmentPattern(factory, elements) {
68927         return factory.createObjectLiteralExpression(ts.map(elements, factory.converters.convertToObjectAssignmentElement));
68928     }
68929     function makeBindingElement(factory, name) {
68930         return factory.createBindingElement(undefined, undefined, name);
68931     }
68932     function makeAssignmentElement(name) {
68933         return name;
68934     }
68935 })(ts || (ts = {}));
68936 var ts;
68937 (function (ts) {
68938     var ProcessLevel;
68939     (function (ProcessLevel) {
68940         ProcessLevel[ProcessLevel["LiftRestriction"] = 0] = "LiftRestriction";
68941         ProcessLevel[ProcessLevel["All"] = 1] = "All";
68942     })(ProcessLevel = ts.ProcessLevel || (ts.ProcessLevel = {}));
68943     function processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, level) {
68944         var tag = ts.visitNode(node.tag, visitor, ts.isExpression);
68945         var templateArguments = [undefined];
68946         var cookedStrings = [];
68947         var rawStrings = [];
68948         var template = node.template;
68949         if (level === ProcessLevel.LiftRestriction && !ts.hasInvalidEscape(template)) {
68950             return ts.visitEachChild(node, visitor, context);
68951         }
68952         if (ts.isNoSubstitutionTemplateLiteral(template)) {
68953             cookedStrings.push(createTemplateCooked(template));
68954             rawStrings.push(getRawLiteral(template, currentSourceFile));
68955         }
68956         else {
68957             cookedStrings.push(createTemplateCooked(template.head));
68958             rawStrings.push(getRawLiteral(template.head, currentSourceFile));
68959             for (var _i = 0, _a = template.templateSpans; _i < _a.length; _i++) {
68960                 var templateSpan = _a[_i];
68961                 cookedStrings.push(createTemplateCooked(templateSpan.literal));
68962                 rawStrings.push(getRawLiteral(templateSpan.literal, currentSourceFile));
68963                 templateArguments.push(ts.visitNode(templateSpan.expression, visitor, ts.isExpression));
68964             }
68965         }
68966         var helperCall = context.getEmitHelperFactory().createTemplateObjectHelper(ts.factory.createArrayLiteralExpression(cookedStrings), ts.factory.createArrayLiteralExpression(rawStrings));
68967         if (ts.isExternalModule(currentSourceFile)) {
68968             var tempVar = ts.factory.createUniqueName("templateObject");
68969             recordTaggedTemplateString(tempVar);
68970             templateArguments[0] = ts.factory.createLogicalOr(tempVar, ts.factory.createAssignment(tempVar, helperCall));
68971         }
68972         else {
68973             templateArguments[0] = helperCall;
68974         }
68975         return ts.factory.createCallExpression(tag, undefined, templateArguments);
68976     }
68977     ts.processTaggedTemplateExpression = processTaggedTemplateExpression;
68978     function createTemplateCooked(template) {
68979         return template.templateFlags ? ts.factory.createVoidZero() : ts.factory.createStringLiteral(template.text);
68980     }
68981     function getRawLiteral(node, currentSourceFile) {
68982         var text = node.rawText;
68983         if (text === undefined) {
68984             text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node);
68985             var isLast = node.kind === 14 || node.kind === 17;
68986             text = text.substring(1, text.length - (isLast ? 1 : 2));
68987         }
68988         text = text.replace(/\r\n?/g, "\n");
68989         return ts.setTextRange(ts.factory.createStringLiteral(text), node);
68990     }
68991 })(ts || (ts = {}));
68992 var ts;
68993 (function (ts) {
68994     var USE_NEW_TYPE_METADATA_FORMAT = false;
68995     function transformTypeScript(context) {
68996         var factory = context.factory, emitHelpers = context.getEmitHelperFactory, startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
68997         var resolver = context.getEmitResolver();
68998         var compilerOptions = context.getCompilerOptions();
68999         var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks");
69000         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
69001         var moduleKind = ts.getEmitModuleKind(compilerOptions);
69002         var previousOnEmitNode = context.onEmitNode;
69003         var previousOnSubstituteNode = context.onSubstituteNode;
69004         context.onEmitNode = onEmitNode;
69005         context.onSubstituteNode = onSubstituteNode;
69006         context.enableSubstitution(201);
69007         context.enableSubstitution(202);
69008         var currentSourceFile;
69009         var currentNamespace;
69010         var currentNamespaceContainerName;
69011         var currentLexicalScope;
69012         var currentNameScope;
69013         var currentScopeFirstDeclarationsOfName;
69014         var currentClassHasParameterProperties;
69015         var enabledSubstitutions;
69016         var classAliases;
69017         var applicableSubstitutions;
69018         return transformSourceFileOrBundle;
69019         function transformSourceFileOrBundle(node) {
69020             if (node.kind === 298) {
69021                 return transformBundle(node);
69022             }
69023             return transformSourceFile(node);
69024         }
69025         function transformBundle(node) {
69026             return factory.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) {
69027                 if (prepend.kind === 300) {
69028                     return ts.createUnparsedSourceFile(prepend, "js");
69029                 }
69030                 return prepend;
69031             }));
69032         }
69033         function transformSourceFile(node) {
69034             if (node.isDeclarationFile) {
69035                 return node;
69036             }
69037             currentSourceFile = node;
69038             var visited = saveStateAndInvoke(node, visitSourceFile);
69039             ts.addEmitHelpers(visited, context.readEmitHelpers());
69040             currentSourceFile = undefined;
69041             return visited;
69042         }
69043         function saveStateAndInvoke(node, f) {
69044             var savedCurrentScope = currentLexicalScope;
69045             var savedCurrentNameScope = currentNameScope;
69046             var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName;
69047             var savedCurrentClassHasParameterProperties = currentClassHasParameterProperties;
69048             onBeforeVisitNode(node);
69049             var visited = f(node);
69050             if (currentLexicalScope !== savedCurrentScope) {
69051                 currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName;
69052             }
69053             currentLexicalScope = savedCurrentScope;
69054             currentNameScope = savedCurrentNameScope;
69055             currentClassHasParameterProperties = savedCurrentClassHasParameterProperties;
69056             return visited;
69057         }
69058         function onBeforeVisitNode(node) {
69059             switch (node.kind) {
69060                 case 297:
69061                 case 258:
69062                 case 257:
69063                 case 230:
69064                     currentLexicalScope = node;
69065                     currentNameScope = undefined;
69066                     currentScopeFirstDeclarationsOfName = undefined;
69067                     break;
69068                 case 252:
69069                 case 251:
69070                     if (ts.hasSyntacticModifier(node, 2)) {
69071                         break;
69072                     }
69073                     if (node.name) {
69074                         recordEmittedDeclarationInScope(node);
69075                     }
69076                     else {
69077                         ts.Debug.assert(node.kind === 252 || ts.hasSyntacticModifier(node, 512));
69078                     }
69079                     if (ts.isClassDeclaration(node)) {
69080                         currentNameScope = node;
69081                     }
69082                     break;
69083             }
69084         }
69085         function visitor(node) {
69086             return saveStateAndInvoke(node, visitorWorker);
69087         }
69088         function visitorWorker(node) {
69089             if (node.transformFlags & 1) {
69090                 return visitTypeScript(node);
69091             }
69092             return node;
69093         }
69094         function sourceElementVisitor(node) {
69095             return saveStateAndInvoke(node, sourceElementVisitorWorker);
69096         }
69097         function sourceElementVisitorWorker(node) {
69098             switch (node.kind) {
69099                 case 261:
69100                 case 260:
69101                 case 266:
69102                 case 267:
69103                     return visitElidableStatement(node);
69104                 default:
69105                     return visitorWorker(node);
69106             }
69107         }
69108         function visitElidableStatement(node) {
69109             var parsed = ts.getParseTreeNode(node);
69110             if (parsed !== node) {
69111                 if (node.transformFlags & 1) {
69112                     return ts.visitEachChild(node, visitor, context);
69113                 }
69114                 return node;
69115             }
69116             switch (node.kind) {
69117                 case 261:
69118                     return visitImportDeclaration(node);
69119                 case 260:
69120                     return visitImportEqualsDeclaration(node);
69121                 case 266:
69122                     return visitExportAssignment(node);
69123                 case 267:
69124                     return visitExportDeclaration(node);
69125                 default:
69126                     ts.Debug.fail("Unhandled ellided statement");
69127             }
69128         }
69129         function namespaceElementVisitor(node) {
69130             return saveStateAndInvoke(node, namespaceElementVisitorWorker);
69131         }
69132         function namespaceElementVisitorWorker(node) {
69133             if (node.kind === 267 ||
69134                 node.kind === 261 ||
69135                 node.kind === 262 ||
69136                 (node.kind === 260 &&
69137                     node.moduleReference.kind === 272)) {
69138                 return undefined;
69139             }
69140             else if (node.transformFlags & 1 || ts.hasSyntacticModifier(node, 1)) {
69141                 return visitTypeScript(node);
69142             }
69143             return node;
69144         }
69145         function classElementVisitor(node) {
69146             return saveStateAndInvoke(node, classElementVisitorWorker);
69147         }
69148         function classElementVisitorWorker(node) {
69149             switch (node.kind) {
69150                 case 166:
69151                     return visitConstructor(node);
69152                 case 163:
69153                     return visitPropertyDeclaration(node);
69154                 case 171:
69155                 case 167:
69156                 case 168:
69157                 case 165:
69158                     return visitorWorker(node);
69159                 case 229:
69160                     return node;
69161                 default:
69162                     return ts.Debug.failBadSyntaxKind(node);
69163             }
69164         }
69165         function modifierVisitor(node) {
69166             if (ts.modifierToFlag(node.kind) & 2270) {
69167                 return undefined;
69168             }
69169             else if (currentNamespace && node.kind === 92) {
69170                 return undefined;
69171             }
69172             return node;
69173         }
69174         function visitTypeScript(node) {
69175             if (ts.isStatement(node) && ts.hasSyntacticModifier(node, 2)) {
69176                 return factory.createNotEmittedStatement(node);
69177             }
69178             switch (node.kind) {
69179                 case 92:
69180                 case 87:
69181                     return currentNamespace ? undefined : node;
69182                 case 122:
69183                 case 120:
69184                 case 121:
69185                 case 125:
69186                 case 84:
69187                 case 133:
69188                 case 142:
69189                 case 178:
69190                 case 179:
69191                 case 180:
69192                 case 181:
69193                 case 177:
69194                 case 172:
69195                 case 159:
69196                 case 128:
69197                 case 152:
69198                 case 131:
69199                 case 147:
69200                 case 144:
69201                 case 141:
69202                 case 113:
69203                 case 148:
69204                 case 175:
69205                 case 174:
69206                 case 176:
69207                 case 173:
69208                 case 182:
69209                 case 183:
69210                 case 184:
69211                 case 186:
69212                 case 187:
69213                 case 188:
69214                 case 189:
69215                 case 190:
69216                 case 191:
69217                 case 171:
69218                 case 161:
69219                 case 254:
69220                     return undefined;
69221                 case 163:
69222                     return visitPropertyDeclaration(node);
69223                 case 259:
69224                     return undefined;
69225                 case 166:
69226                     return visitConstructor(node);
69227                 case 253:
69228                     return factory.createNotEmittedStatement(node);
69229                 case 252:
69230                     return visitClassDeclaration(node);
69231                 case 221:
69232                     return visitClassExpression(node);
69233                 case 286:
69234                     return visitHeritageClause(node);
69235                 case 223:
69236                     return visitExpressionWithTypeArguments(node);
69237                 case 165:
69238                     return visitMethodDeclaration(node);
69239                 case 167:
69240                     return visitGetAccessor(node);
69241                 case 168:
69242                     return visitSetAccessor(node);
69243                 case 251:
69244                     return visitFunctionDeclaration(node);
69245                 case 208:
69246                     return visitFunctionExpression(node);
69247                 case 209:
69248                     return visitArrowFunction(node);
69249                 case 160:
69250                     return visitParameter(node);
69251                 case 207:
69252                     return visitParenthesizedExpression(node);
69253                 case 206:
69254                 case 224:
69255                     return visitAssertionExpression(node);
69256                 case 203:
69257                     return visitCallExpression(node);
69258                 case 204:
69259                     return visitNewExpression(node);
69260                 case 205:
69261                     return visitTaggedTemplateExpression(node);
69262                 case 225:
69263                     return visitNonNullExpression(node);
69264                 case 255:
69265                     return visitEnumDeclaration(node);
69266                 case 232:
69267                     return visitVariableStatement(node);
69268                 case 249:
69269                     return visitVariableDeclaration(node);
69270                 case 256:
69271                     return visitModuleDeclaration(node);
69272                 case 260:
69273                     return visitImportEqualsDeclaration(node);
69274                 case 274:
69275                     return visitJsxSelfClosingElement(node);
69276                 case 275:
69277                     return visitJsxJsxOpeningElement(node);
69278                 default:
69279                     return ts.visitEachChild(node, visitor, context);
69280             }
69281         }
69282         function visitSourceFile(node) {
69283             var alwaysStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") &&
69284                 !(ts.isExternalModule(node) && moduleKind >= ts.ModuleKind.ES2015) &&
69285                 !ts.isJsonSourceFile(node);
69286             return factory.updateSourceFile(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, 0, alwaysStrict));
69287         }
69288         function shouldEmitDecorateCallForClass(node) {
69289             if (node.decorators && node.decorators.length > 0) {
69290                 return true;
69291             }
69292             var constructor = ts.getFirstConstructorWithBody(node);
69293             if (constructor) {
69294                 return ts.forEach(constructor.parameters, shouldEmitDecorateCallForParameter);
69295             }
69296             return false;
69297         }
69298         function shouldEmitDecorateCallForParameter(parameter) {
69299             return parameter.decorators !== undefined && parameter.decorators.length > 0;
69300         }
69301         function getClassFacts(node, staticProperties) {
69302             var facts = 0;
69303             if (ts.some(staticProperties))
69304                 facts |= 1;
69305             var extendsClauseElement = ts.getEffectiveBaseTypeNode(node);
69306             if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103)
69307                 facts |= 64;
69308             if (shouldEmitDecorateCallForClass(node))
69309                 facts |= 2;
69310             if (ts.childIsDecorated(node))
69311                 facts |= 4;
69312             if (isExportOfNamespace(node))
69313                 facts |= 8;
69314             else if (isDefaultExternalModuleExport(node))
69315                 facts |= 32;
69316             else if (isNamedExternalModuleExport(node))
69317                 facts |= 16;
69318             if (languageVersion <= 1 && (facts & 7))
69319                 facts |= 128;
69320             return facts;
69321         }
69322         function hasTypeScriptClassSyntax(node) {
69323             return !!(node.transformFlags & 2048);
69324         }
69325         function isClassLikeDeclarationWithTypeScriptSyntax(node) {
69326             return ts.some(node.decorators)
69327                 || ts.some(node.typeParameters)
69328                 || ts.some(node.heritageClauses, hasTypeScriptClassSyntax)
69329                 || ts.some(node.members, hasTypeScriptClassSyntax);
69330         }
69331         function visitClassDeclaration(node) {
69332             if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1))) {
69333                 return ts.visitEachChild(node, visitor, context);
69334             }
69335             var staticProperties = ts.getProperties(node, true, true);
69336             var facts = getClassFacts(node, staticProperties);
69337             if (facts & 128) {
69338                 context.startLexicalEnvironment();
69339             }
69340             var name = node.name || (facts & 5 ? factory.getGeneratedNameForNode(node) : undefined);
69341             var classStatement = facts & 2
69342                 ? createClassDeclarationHeadWithDecorators(node, name)
69343                 : createClassDeclarationHeadWithoutDecorators(node, name, facts);
69344             var statements = [classStatement];
69345             addClassElementDecorationStatements(statements, node, false);
69346             addClassElementDecorationStatements(statements, node, true);
69347             addConstructorDecorationStatement(statements, node);
69348             if (facts & 128) {
69349                 var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19);
69350                 var localName = factory.getInternalName(node);
69351                 var outer = factory.createPartiallyEmittedExpression(localName);
69352                 ts.setTextRangeEnd(outer, closingBraceLocation.end);
69353                 ts.setEmitFlags(outer, 1536);
69354                 var statement = factory.createReturnStatement(outer);
69355                 ts.setTextRangePos(statement, closingBraceLocation.pos);
69356                 ts.setEmitFlags(statement, 1536 | 384);
69357                 statements.push(statement);
69358                 ts.insertStatementsAfterStandardPrologue(statements, context.endLexicalEnvironment());
69359                 var iife = factory.createImmediatelyInvokedArrowFunction(statements);
69360                 ts.setEmitFlags(iife, 33554432);
69361                 var varStatement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
69362                     factory.createVariableDeclaration(factory.getLocalName(node, false, false), undefined, undefined, iife)
69363                 ]));
69364                 ts.setOriginalNode(varStatement, node);
69365                 ts.setCommentRange(varStatement, node);
69366                 ts.setSourceMapRange(varStatement, ts.moveRangePastDecorators(node));
69367                 ts.startOnNewLine(varStatement);
69368                 statements = [varStatement];
69369             }
69370             if (facts & 8) {
69371                 addExportMemberAssignment(statements, node);
69372             }
69373             else if (facts & 128 || facts & 2) {
69374                 if (facts & 32) {
69375                     statements.push(factory.createExportDefault(factory.getLocalName(node, false, true)));
69376                 }
69377                 else if (facts & 16) {
69378                     statements.push(factory.createExternalModuleExport(factory.getLocalName(node, false, true)));
69379                 }
69380             }
69381             if (statements.length > 1) {
69382                 statements.push(factory.createEndOfDeclarationMarker(node));
69383                 ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304);
69384             }
69385             return ts.singleOrMany(statements);
69386         }
69387         function createClassDeclarationHeadWithoutDecorators(node, name, facts) {
69388             var modifiers = !(facts & 128)
69389                 ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier)
69390                 : undefined;
69391             var classDeclaration = factory.createClassDeclaration(undefined, modifiers, name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
69392             var emitFlags = ts.getEmitFlags(node);
69393             if (facts & 1) {
69394                 emitFlags |= 32;
69395             }
69396             ts.setTextRange(classDeclaration, node);
69397             ts.setOriginalNode(classDeclaration, node);
69398             ts.setEmitFlags(classDeclaration, emitFlags);
69399             return classDeclaration;
69400         }
69401         function createClassDeclarationHeadWithDecorators(node, name) {
69402             var location = ts.moveRangePastDecorators(node);
69403             var classAlias = getClassAliasIfNeeded(node);
69404             var declName = factory.getLocalName(node, false, true);
69405             var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
69406             var members = transformClassMembers(node);
69407             var classExpression = factory.createClassExpression(undefined, undefined, name, undefined, heritageClauses, members);
69408             ts.setOriginalNode(classExpression, node);
69409             ts.setTextRange(classExpression, location);
69410             var statement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
69411                 factory.createVariableDeclaration(declName, undefined, undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression)
69412             ], 1));
69413             ts.setOriginalNode(statement, node);
69414             ts.setTextRange(statement, location);
69415             ts.setCommentRange(statement, node);
69416             return statement;
69417         }
69418         function visitClassExpression(node) {
69419             if (!isClassLikeDeclarationWithTypeScriptSyntax(node)) {
69420                 return ts.visitEachChild(node, visitor, context);
69421             }
69422             var classExpression = factory.createClassExpression(undefined, undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
69423             ts.setOriginalNode(classExpression, node);
69424             ts.setTextRange(classExpression, node);
69425             return classExpression;
69426         }
69427         function transformClassMembers(node) {
69428             var members = [];
69429             var constructor = ts.getFirstConstructorWithBody(node);
69430             var parametersWithPropertyAssignments = constructor &&
69431                 ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); });
69432             if (parametersWithPropertyAssignments) {
69433                 for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) {
69434                     var parameter = parametersWithPropertyAssignments_1[_i];
69435                     if (ts.isIdentifier(parameter.name)) {
69436                         members.push(ts.setOriginalNode(factory.createPropertyDeclaration(undefined, undefined, parameter.name, undefined, undefined, undefined), parameter));
69437                     }
69438                 }
69439             }
69440             ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement));
69441             return ts.setTextRange(factory.createNodeArray(members), node.members);
69442         }
69443         function getDecoratedClassElements(node, isStatic) {
69444             return ts.filter(node.members, isStatic ? function (m) { return isStaticDecoratedClassElement(m, node); } : function (m) { return isInstanceDecoratedClassElement(m, node); });
69445         }
69446         function isStaticDecoratedClassElement(member, parent) {
69447             return isDecoratedClassElement(member, true, parent);
69448         }
69449         function isInstanceDecoratedClassElement(member, parent) {
69450             return isDecoratedClassElement(member, false, parent);
69451         }
69452         function isDecoratedClassElement(member, isStatic, parent) {
69453             return ts.nodeOrChildIsDecorated(member, parent)
69454                 && isStatic === ts.hasSyntacticModifier(member, 32);
69455         }
69456         function getDecoratorsOfParameters(node) {
69457             var decorators;
69458             if (node) {
69459                 var parameters = node.parameters;
69460                 var firstParameterIsThis = parameters.length > 0 && ts.parameterIsThisKeyword(parameters[0]);
69461                 var firstParameterOffset = firstParameterIsThis ? 1 : 0;
69462                 var numParameters = firstParameterIsThis ? parameters.length - 1 : parameters.length;
69463                 for (var i = 0; i < numParameters; i++) {
69464                     var parameter = parameters[i + firstParameterOffset];
69465                     if (decorators || parameter.decorators) {
69466                         if (!decorators) {
69467                             decorators = new Array(numParameters);
69468                         }
69469                         decorators[i] = parameter.decorators;
69470                     }
69471                 }
69472             }
69473             return decorators;
69474         }
69475         function getAllDecoratorsOfConstructor(node) {
69476             var decorators = node.decorators;
69477             var parameters = getDecoratorsOfParameters(ts.getFirstConstructorWithBody(node));
69478             if (!decorators && !parameters) {
69479                 return undefined;
69480             }
69481             return {
69482                 decorators: decorators,
69483                 parameters: parameters
69484             };
69485         }
69486         function getAllDecoratorsOfClassElement(node, member) {
69487             switch (member.kind) {
69488                 case 167:
69489                 case 168:
69490                     return getAllDecoratorsOfAccessors(node, member);
69491                 case 165:
69492                     return getAllDecoratorsOfMethod(member);
69493                 case 163:
69494                     return getAllDecoratorsOfProperty(member);
69495                 default:
69496                     return undefined;
69497             }
69498         }
69499         function getAllDecoratorsOfAccessors(node, accessor) {
69500             if (!accessor.body) {
69501                 return undefined;
69502             }
69503             var _a = ts.getAllAccessorDeclarations(node.members, accessor), firstAccessor = _a.firstAccessor, secondAccessor = _a.secondAccessor, setAccessor = _a.setAccessor;
69504             var firstAccessorWithDecorators = firstAccessor.decorators ? firstAccessor : secondAccessor && secondAccessor.decorators ? secondAccessor : undefined;
69505             if (!firstAccessorWithDecorators || accessor !== firstAccessorWithDecorators) {
69506                 return undefined;
69507             }
69508             var decorators = firstAccessorWithDecorators.decorators;
69509             var parameters = getDecoratorsOfParameters(setAccessor);
69510             if (!decorators && !parameters) {
69511                 return undefined;
69512             }
69513             return { decorators: decorators, parameters: parameters };
69514         }
69515         function getAllDecoratorsOfMethod(method) {
69516             if (!method.body) {
69517                 return undefined;
69518             }
69519             var decorators = method.decorators;
69520             var parameters = getDecoratorsOfParameters(method);
69521             if (!decorators && !parameters) {
69522                 return undefined;
69523             }
69524             return { decorators: decorators, parameters: parameters };
69525         }
69526         function getAllDecoratorsOfProperty(property) {
69527             var decorators = property.decorators;
69528             if (!decorators) {
69529                 return undefined;
69530             }
69531             return { decorators: decorators };
69532         }
69533         function transformAllDecoratorsOfDeclaration(node, container, allDecorators) {
69534             if (!allDecorators) {
69535                 return undefined;
69536             }
69537             var decoratorExpressions = [];
69538             ts.addRange(decoratorExpressions, ts.map(allDecorators.decorators, transformDecorator));
69539             ts.addRange(decoratorExpressions, ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter));
69540             addTypeMetadata(node, container, decoratorExpressions);
69541             return decoratorExpressions;
69542         }
69543         function addClassElementDecorationStatements(statements, node, isStatic) {
69544             ts.addRange(statements, ts.map(generateClassElementDecorationExpressions(node, isStatic), expressionToStatement));
69545         }
69546         function generateClassElementDecorationExpressions(node, isStatic) {
69547             var members = getDecoratedClassElements(node, isStatic);
69548             var expressions;
69549             for (var _i = 0, members_6 = members; _i < members_6.length; _i++) {
69550                 var member = members_6[_i];
69551                 var expression = generateClassElementDecorationExpression(node, member);
69552                 if (expression) {
69553                     if (!expressions) {
69554                         expressions = [expression];
69555                     }
69556                     else {
69557                         expressions.push(expression);
69558                     }
69559                 }
69560             }
69561             return expressions;
69562         }
69563         function generateClassElementDecorationExpression(node, member) {
69564             var allDecorators = getAllDecoratorsOfClassElement(node, member);
69565             var decoratorExpressions = transformAllDecoratorsOfDeclaration(member, node, allDecorators);
69566             if (!decoratorExpressions) {
69567                 return undefined;
69568             }
69569             var prefix = getClassMemberPrefix(node, member);
69570             var memberName = getExpressionForPropertyName(member, true);
69571             var descriptor = languageVersion > 0
69572                 ? member.kind === 163
69573                     ? factory.createVoidZero()
69574                     : factory.createNull()
69575                 : undefined;
69576             var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor);
69577             ts.setTextRange(helper, ts.moveRangePastDecorators(member));
69578             ts.setEmitFlags(helper, 1536);
69579             return helper;
69580         }
69581         function addConstructorDecorationStatement(statements, node) {
69582             var expression = generateConstructorDecorationExpression(node);
69583             if (expression) {
69584                 statements.push(ts.setOriginalNode(factory.createExpressionStatement(expression), node));
69585             }
69586         }
69587         function generateConstructorDecorationExpression(node) {
69588             var allDecorators = getAllDecoratorsOfConstructor(node);
69589             var decoratorExpressions = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
69590             if (!decoratorExpressions) {
69591                 return undefined;
69592             }
69593             var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)];
69594             var localName = factory.getLocalName(node, false, true);
69595             var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName);
69596             var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate);
69597             ts.setEmitFlags(expression, 1536);
69598             ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node));
69599             return expression;
69600         }
69601         function transformDecorator(decorator) {
69602             return ts.visitNode(decorator.expression, visitor, ts.isExpression);
69603         }
69604         function transformDecoratorsOfParameter(decorators, parameterOffset) {
69605             var expressions;
69606             if (decorators) {
69607                 expressions = [];
69608                 for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) {
69609                     var decorator = decorators_1[_i];
69610                     var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset);
69611                     ts.setTextRange(helper, decorator.expression);
69612                     ts.setEmitFlags(helper, 1536);
69613                     expressions.push(helper);
69614                 }
69615             }
69616             return expressions;
69617         }
69618         function addTypeMetadata(node, container, decoratorExpressions) {
69619             if (USE_NEW_TYPE_METADATA_FORMAT) {
69620                 addNewTypeMetadata(node, container, decoratorExpressions);
69621             }
69622             else {
69623                 addOldTypeMetadata(node, container, decoratorExpressions);
69624             }
69625         }
69626         function addOldTypeMetadata(node, container, decoratorExpressions) {
69627             if (compilerOptions.emitDecoratorMetadata) {
69628                 if (shouldAddTypeMetadata(node)) {
69629                     decoratorExpressions.push(emitHelpers().createMetadataHelper("design:type", serializeTypeOfNode(node)));
69630                 }
69631                 if (shouldAddParamTypesMetadata(node)) {
69632                     decoratorExpressions.push(emitHelpers().createMetadataHelper("design:paramtypes", serializeParameterTypesOfNode(node, container)));
69633                 }
69634                 if (shouldAddReturnTypeMetadata(node)) {
69635                     decoratorExpressions.push(emitHelpers().createMetadataHelper("design:returntype", serializeReturnTypeOfNode(node)));
69636                 }
69637             }
69638         }
69639         function addNewTypeMetadata(node, container, decoratorExpressions) {
69640             if (compilerOptions.emitDecoratorMetadata) {
69641                 var properties = void 0;
69642                 if (shouldAddTypeMetadata(node)) {
69643                     (properties || (properties = [])).push(factory.createPropertyAssignment("type", factory.createArrowFunction(undefined, undefined, [], undefined, factory.createToken(38), serializeTypeOfNode(node))));
69644                 }
69645                 if (shouldAddParamTypesMetadata(node)) {
69646                     (properties || (properties = [])).push(factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(undefined, undefined, [], undefined, factory.createToken(38), serializeParameterTypesOfNode(node, container))));
69647                 }
69648                 if (shouldAddReturnTypeMetadata(node)) {
69649                     (properties || (properties = [])).push(factory.createPropertyAssignment("returnType", factory.createArrowFunction(undefined, undefined, [], undefined, factory.createToken(38), serializeReturnTypeOfNode(node))));
69650                 }
69651                 if (properties) {
69652                     decoratorExpressions.push(emitHelpers().createMetadataHelper("design:typeinfo", factory.createObjectLiteralExpression(properties, true)));
69653                 }
69654             }
69655         }
69656         function shouldAddTypeMetadata(node) {
69657             var kind = node.kind;
69658             return kind === 165
69659                 || kind === 167
69660                 || kind === 168
69661                 || kind === 163;
69662         }
69663         function shouldAddReturnTypeMetadata(node) {
69664             return node.kind === 165;
69665         }
69666         function shouldAddParamTypesMetadata(node) {
69667             switch (node.kind) {
69668                 case 252:
69669                 case 221:
69670                     return ts.getFirstConstructorWithBody(node) !== undefined;
69671                 case 165:
69672                 case 167:
69673                 case 168:
69674                     return true;
69675             }
69676             return false;
69677         }
69678         function getAccessorTypeNode(node) {
69679             var accessors = resolver.getAllAccessorDeclarations(node);
69680             return accessors.setAccessor && ts.getSetAccessorTypeAnnotationNode(accessors.setAccessor)
69681                 || accessors.getAccessor && ts.getEffectiveReturnTypeNode(accessors.getAccessor);
69682         }
69683         function serializeTypeOfNode(node) {
69684             switch (node.kind) {
69685                 case 163:
69686                 case 160:
69687                     return serializeTypeNode(node.type);
69688                 case 168:
69689                 case 167:
69690                     return serializeTypeNode(getAccessorTypeNode(node));
69691                 case 252:
69692                 case 221:
69693                 case 165:
69694                     return factory.createIdentifier("Function");
69695                 default:
69696                     return factory.createVoidZero();
69697             }
69698         }
69699         function serializeParameterTypesOfNode(node, container) {
69700             var valueDeclaration = ts.isClassLike(node)
69701                 ? ts.getFirstConstructorWithBody(node)
69702                 : ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)
69703                     ? node
69704                     : undefined;
69705             var expressions = [];
69706             if (valueDeclaration) {
69707                 var parameters = getParametersOfDecoratedDeclaration(valueDeclaration, container);
69708                 var numParameters = parameters.length;
69709                 for (var i = 0; i < numParameters; i++) {
69710                     var parameter = parameters[i];
69711                     if (i === 0 && ts.isIdentifier(parameter.name) && parameter.name.escapedText === "this") {
69712                         continue;
69713                     }
69714                     if (parameter.dotDotDotToken) {
69715                         expressions.push(serializeTypeNode(ts.getRestParameterElementType(parameter.type)));
69716                     }
69717                     else {
69718                         expressions.push(serializeTypeOfNode(parameter));
69719                     }
69720                 }
69721             }
69722             return factory.createArrayLiteralExpression(expressions);
69723         }
69724         function getParametersOfDecoratedDeclaration(node, container) {
69725             if (container && node.kind === 167) {
69726                 var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor;
69727                 if (setAccessor) {
69728                     return setAccessor.parameters;
69729                 }
69730             }
69731             return node.parameters;
69732         }
69733         function serializeReturnTypeOfNode(node) {
69734             if (ts.isFunctionLike(node) && node.type) {
69735                 return serializeTypeNode(node.type);
69736             }
69737             else if (ts.isAsyncFunction(node)) {
69738                 return factory.createIdentifier("Promise");
69739             }
69740             return factory.createVoidZero();
69741         }
69742         function serializeTypeNode(node) {
69743             if (node === undefined) {
69744                 return factory.createIdentifier("Object");
69745             }
69746             switch (node.kind) {
69747                 case 113:
69748                 case 150:
69749                 case 141:
69750                     return factory.createVoidZero();
69751                 case 186:
69752                     return serializeTypeNode(node.type);
69753                 case 174:
69754                 case 175:
69755                     return factory.createIdentifier("Function");
69756                 case 178:
69757                 case 179:
69758                     return factory.createIdentifier("Array");
69759                 case 172:
69760                 case 131:
69761                     return factory.createIdentifier("Boolean");
69762                 case 147:
69763                     return factory.createIdentifier("String");
69764                 case 145:
69765                     return factory.createIdentifier("Object");
69766                 case 191:
69767                     switch (node.literal.kind) {
69768                         case 10:
69769                         case 14:
69770                             return factory.createIdentifier("String");
69771                         case 214:
69772                         case 8:
69773                             return factory.createIdentifier("Number");
69774                         case 9:
69775                             return getGlobalBigIntNameWithFallback();
69776                         case 109:
69777                         case 94:
69778                             return factory.createIdentifier("Boolean");
69779                         case 103:
69780                             return factory.createVoidZero();
69781                         default:
69782                             return ts.Debug.failBadSyntaxKind(node.literal);
69783                     }
69784                 case 144:
69785                     return factory.createIdentifier("Number");
69786                 case 155:
69787                     return getGlobalBigIntNameWithFallback();
69788                 case 148:
69789                     return languageVersion < 2
69790                         ? getGlobalSymbolNameWithFallback()
69791                         : factory.createIdentifier("Symbol");
69792                 case 173:
69793                     return serializeTypeReferenceNode(node);
69794                 case 183:
69795                 case 182:
69796                     return serializeTypeList(node.types);
69797                 case 184:
69798                     return serializeTypeList([node.trueType, node.falseType]);
69799                 case 188:
69800                     if (node.operator === 142) {
69801                         return serializeTypeNode(node.type);
69802                     }
69803                     break;
69804                 case 176:
69805                 case 189:
69806                 case 190:
69807                 case 177:
69808                 case 128:
69809                 case 152:
69810                 case 187:
69811                 case 195:
69812                     break;
69813                 case 303:
69814                 case 304:
69815                 case 308:
69816                 case 309:
69817                 case 310:
69818                     break;
69819                 case 305:
69820                 case 306:
69821                 case 307:
69822                     return serializeTypeNode(node.type);
69823                 default:
69824                     return ts.Debug.failBadSyntaxKind(node);
69825             }
69826             return factory.createIdentifier("Object");
69827         }
69828         function serializeTypeList(types) {
69829             var serializedUnion;
69830             for (var _i = 0, types_22 = types; _i < types_22.length; _i++) {
69831                 var typeNode = types_22[_i];
69832                 while (typeNode.kind === 186) {
69833                     typeNode = typeNode.type;
69834                 }
69835                 if (typeNode.kind === 141) {
69836                     continue;
69837                 }
69838                 if (!strictNullChecks && (typeNode.kind === 191 && typeNode.literal.kind === 103 || typeNode.kind === 150)) {
69839                     continue;
69840                 }
69841                 var serializedIndividual = serializeTypeNode(typeNode);
69842                 if (ts.isIdentifier(serializedIndividual) && serializedIndividual.escapedText === "Object") {
69843                     return serializedIndividual;
69844                 }
69845                 else if (serializedUnion) {
69846                     if (!ts.isIdentifier(serializedUnion) ||
69847                         !ts.isIdentifier(serializedIndividual) ||
69848                         serializedUnion.escapedText !== serializedIndividual.escapedText) {
69849                         return factory.createIdentifier("Object");
69850                     }
69851                 }
69852                 else {
69853                     serializedUnion = serializedIndividual;
69854                 }
69855             }
69856             return serializedUnion || factory.createVoidZero();
69857         }
69858         function serializeTypeReferenceNode(node) {
69859             var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope);
69860             switch (kind) {
69861                 case ts.TypeReferenceSerializationKind.Unknown:
69862                     if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) {
69863                         return factory.createIdentifier("Object");
69864                     }
69865                     var serialized = serializeEntityNameAsExpressionFallback(node.typeName);
69866                     var temp = factory.createTempVariable(hoistVariableDeclaration);
69867                     return factory.createConditionalExpression(factory.createTypeCheck(factory.createAssignment(temp, serialized), "function"), undefined, temp, undefined, factory.createIdentifier("Object"));
69868                 case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue:
69869                     return serializeEntityNameAsExpression(node.typeName);
69870                 case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType:
69871                     return factory.createVoidZero();
69872                 case ts.TypeReferenceSerializationKind.BigIntLikeType:
69873                     return getGlobalBigIntNameWithFallback();
69874                 case ts.TypeReferenceSerializationKind.BooleanType:
69875                     return factory.createIdentifier("Boolean");
69876                 case ts.TypeReferenceSerializationKind.NumberLikeType:
69877                     return factory.createIdentifier("Number");
69878                 case ts.TypeReferenceSerializationKind.StringLikeType:
69879                     return factory.createIdentifier("String");
69880                 case ts.TypeReferenceSerializationKind.ArrayLikeType:
69881                     return factory.createIdentifier("Array");
69882                 case ts.TypeReferenceSerializationKind.ESSymbolType:
69883                     return languageVersion < 2
69884                         ? getGlobalSymbolNameWithFallback()
69885                         : factory.createIdentifier("Symbol");
69886                 case ts.TypeReferenceSerializationKind.TypeWithCallSignature:
69887                     return factory.createIdentifier("Function");
69888                 case ts.TypeReferenceSerializationKind.Promise:
69889                     return factory.createIdentifier("Promise");
69890                 case ts.TypeReferenceSerializationKind.ObjectType:
69891                     return factory.createIdentifier("Object");
69892                 default:
69893                     return ts.Debug.assertNever(kind);
69894             }
69895         }
69896         function createCheckedValue(left, right) {
69897             return factory.createLogicalAnd(factory.createStrictInequality(factory.createTypeOfExpression(left), factory.createStringLiteral("undefined")), right);
69898         }
69899         function serializeEntityNameAsExpressionFallback(node) {
69900             if (node.kind === 78) {
69901                 var copied = serializeEntityNameAsExpression(node);
69902                 return createCheckedValue(copied, copied);
69903             }
69904             if (node.left.kind === 78) {
69905                 return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node));
69906             }
69907             var left = serializeEntityNameAsExpressionFallback(node.left);
69908             var temp = factory.createTempVariable(hoistVariableDeclaration);
69909             return factory.createLogicalAnd(factory.createLogicalAnd(left.left, factory.createStrictInequality(factory.createAssignment(temp, left.right), factory.createVoidZero())), factory.createPropertyAccessExpression(temp, node.right));
69910         }
69911         function serializeEntityNameAsExpression(node) {
69912             switch (node.kind) {
69913                 case 78:
69914                     var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent);
69915                     name.original = undefined;
69916                     ts.setParent(name, ts.getParseTreeNode(currentLexicalScope));
69917                     return name;
69918                 case 157:
69919                     return serializeQualifiedNameAsExpression(node);
69920             }
69921         }
69922         function serializeQualifiedNameAsExpression(node) {
69923             return factory.createPropertyAccessExpression(serializeEntityNameAsExpression(node.left), node.right);
69924         }
69925         function getGlobalSymbolNameWithFallback() {
69926             return factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("Symbol"), "function"), undefined, factory.createIdentifier("Symbol"), undefined, factory.createIdentifier("Object"));
69927         }
69928         function getGlobalBigIntNameWithFallback() {
69929             return languageVersion < 99
69930                 ? factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("BigInt"), "function"), undefined, factory.createIdentifier("BigInt"), undefined, factory.createIdentifier("Object"))
69931                 : factory.createIdentifier("BigInt");
69932         }
69933         function getExpressionForPropertyName(member, generateNameForComputedPropertyName) {
69934             var name = member.name;
69935             if (ts.isPrivateIdentifier(name)) {
69936                 return factory.createIdentifier("");
69937             }
69938             else if (ts.isComputedPropertyName(name)) {
69939                 return generateNameForComputedPropertyName && !ts.isSimpleInlineableExpression(name.expression)
69940                     ? factory.getGeneratedNameForNode(name)
69941                     : name.expression;
69942             }
69943             else if (ts.isIdentifier(name)) {
69944                 return factory.createStringLiteral(ts.idText(name));
69945             }
69946             else {
69947                 return factory.cloneNode(name);
69948             }
69949         }
69950         function visitPropertyNameOfClassElement(member) {
69951             var name = member.name;
69952             if (ts.isComputedPropertyName(name) && ((!ts.hasStaticModifier(member) && currentClassHasParameterProperties) || ts.some(member.decorators))) {
69953                 var expression = ts.visitNode(name.expression, visitor, ts.isExpression);
69954                 var innerExpression = ts.skipPartiallyEmittedExpressions(expression);
69955                 if (!ts.isSimpleInlineableExpression(innerExpression)) {
69956                     var generatedName = factory.getGeneratedNameForNode(name);
69957                     hoistVariableDeclaration(generatedName);
69958                     return factory.updateComputedPropertyName(name, factory.createAssignment(generatedName, expression));
69959                 }
69960             }
69961             return ts.visitNode(name, visitor, ts.isPropertyName);
69962         }
69963         function visitHeritageClause(node) {
69964             if (node.token === 116) {
69965                 return undefined;
69966             }
69967             return ts.visitEachChild(node, visitor, context);
69968         }
69969         function visitExpressionWithTypeArguments(node) {
69970             return factory.updateExpressionWithTypeArguments(node, ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression), undefined);
69971         }
69972         function shouldEmitFunctionLikeDeclaration(node) {
69973             return !ts.nodeIsMissing(node.body);
69974         }
69975         function visitPropertyDeclaration(node) {
69976             if (node.flags & 8388608) {
69977                 return undefined;
69978             }
69979             var updated = factory.updatePropertyDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), undefined, undefined, ts.visitNode(node.initializer, visitor));
69980             if (updated !== node) {
69981                 ts.setCommentRange(updated, node);
69982                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
69983             }
69984             return updated;
69985         }
69986         function visitConstructor(node) {
69987             if (!shouldEmitFunctionLikeDeclaration(node)) {
69988                 return undefined;
69989             }
69990             return factory.updateConstructorDeclaration(node, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), transformConstructorBody(node.body, node));
69991         }
69992         function transformConstructorBody(body, constructor) {
69993             var parametersWithPropertyAssignments = constructor &&
69994                 ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); });
69995             if (!ts.some(parametersWithPropertyAssignments)) {
69996                 return ts.visitFunctionBody(body, visitor, context);
69997             }
69998             var statements = [];
69999             var indexOfFirstStatement = 0;
70000             resumeLexicalEnvironment();
70001             indexOfFirstStatement = ts.addPrologueDirectivesAndInitialSuperCall(factory, constructor, statements, visitor);
70002             ts.addRange(statements, ts.map(parametersWithPropertyAssignments, transformParameterWithPropertyAssignment));
70003             ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexOfFirstStatement));
70004             statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
70005             var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), true);
70006             ts.setTextRange(block, body);
70007             ts.setOriginalNode(block, body);
70008             return block;
70009         }
70010         function transformParameterWithPropertyAssignment(node) {
70011             var name = node.name;
70012             if (!ts.isIdentifier(name)) {
70013                 return undefined;
70014             }
70015             var propertyName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent);
70016             ts.setEmitFlags(propertyName, 1536 | 48);
70017             var localName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent);
70018             ts.setEmitFlags(localName, 1536);
70019             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))));
70020         }
70021         function visitMethodDeclaration(node) {
70022             if (!shouldEmitFunctionLikeDeclaration(node)) {
70023                 return undefined;
70024             }
70025             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));
70026             if (updated !== node) {
70027                 ts.setCommentRange(updated, node);
70028                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
70029             }
70030             return updated;
70031         }
70032         function shouldEmitAccessorDeclaration(node) {
70033             return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128));
70034         }
70035         function visitGetAccessor(node) {
70036             if (!shouldEmitAccessorDeclaration(node)) {
70037                 return undefined;
70038             }
70039             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([]));
70040             if (updated !== node) {
70041                 ts.setCommentRange(updated, node);
70042                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
70043             }
70044             return updated;
70045         }
70046         function visitSetAccessor(node) {
70047             if (!shouldEmitAccessorDeclaration(node)) {
70048                 return undefined;
70049             }
70050             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([]));
70051             if (updated !== node) {
70052                 ts.setCommentRange(updated, node);
70053                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
70054             }
70055             return updated;
70056         }
70057         function visitFunctionDeclaration(node) {
70058             if (!shouldEmitFunctionLikeDeclaration(node)) {
70059                 return factory.createNotEmittedStatement(node);
70060             }
70061             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([]));
70062             if (isExportOfNamespace(node)) {
70063                 var statements = [updated];
70064                 addExportMemberAssignment(statements, node);
70065                 return statements;
70066             }
70067             return updated;
70068         }
70069         function visitFunctionExpression(node) {
70070             if (!shouldEmitFunctionLikeDeclaration(node)) {
70071                 return factory.createOmittedExpression();
70072             }
70073             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([]));
70074             return updated;
70075         }
70076         function visitArrowFunction(node) {
70077             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));
70078             return updated;
70079         }
70080         function visitParameter(node) {
70081             if (ts.parameterIsThisKeyword(node)) {
70082                 return undefined;
70083             }
70084             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));
70085             if (updated !== node) {
70086                 ts.setCommentRange(updated, node);
70087                 ts.setTextRange(updated, ts.moveRangePastModifiers(node));
70088                 ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node));
70089                 ts.setEmitFlags(updated.name, 32);
70090             }
70091             return updated;
70092         }
70093         function visitVariableStatement(node) {
70094             if (isExportOfNamespace(node)) {
70095                 var variables = ts.getInitializedVariables(node.declarationList);
70096                 if (variables.length === 0) {
70097                     return undefined;
70098                 }
70099                 return ts.setTextRange(factory.createExpressionStatement(factory.inlineExpressions(ts.map(variables, transformInitializedVariable))), node);
70100             }
70101             else {
70102                 return ts.visitEachChild(node, visitor, context);
70103             }
70104         }
70105         function transformInitializedVariable(node) {
70106             var name = node.name;
70107             if (ts.isBindingPattern(name)) {
70108                 return ts.flattenDestructuringAssignment(node, visitor, context, 0, false, createNamespaceExportExpression);
70109             }
70110             else {
70111                 return ts.setTextRange(factory.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression)), node);
70112             }
70113         }
70114         function visitVariableDeclaration(node) {
70115             return factory.updateVariableDeclaration(node, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
70116         }
70117         function visitParenthesizedExpression(node) {
70118             var innerExpression = ts.skipOuterExpressions(node.expression, ~6);
70119             if (ts.isAssertionExpression(innerExpression)) {
70120                 var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
70121                 if (ts.length(ts.getLeadingCommentRangesOfNode(expression, currentSourceFile))) {
70122                     return factory.updateParenthesizedExpression(node, expression);
70123                 }
70124                 return factory.createPartiallyEmittedExpression(expression, node);
70125             }
70126             return ts.visitEachChild(node, visitor, context);
70127         }
70128         function visitAssertionExpression(node) {
70129             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
70130             return factory.createPartiallyEmittedExpression(expression, node);
70131         }
70132         function visitNonNullExpression(node) {
70133             var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression);
70134             return factory.createPartiallyEmittedExpression(expression, node);
70135         }
70136         function visitCallExpression(node) {
70137             return factory.updateCallExpression(node, ts.visitNode(node.expression, visitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression));
70138         }
70139         function visitNewExpression(node) {
70140             return factory.updateNewExpression(node, ts.visitNode(node.expression, visitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression));
70141         }
70142         function visitTaggedTemplateExpression(node) {
70143             return factory.updateTaggedTemplateExpression(node, ts.visitNode(node.tag, visitor, ts.isExpression), undefined, ts.visitNode(node.template, visitor, ts.isExpression));
70144         }
70145         function visitJsxSelfClosingElement(node) {
70146             return factory.updateJsxSelfClosingElement(node, ts.visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), undefined, ts.visitNode(node.attributes, visitor, ts.isJsxAttributes));
70147         }
70148         function visitJsxJsxOpeningElement(node) {
70149             return factory.updateJsxOpeningElement(node, ts.visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), undefined, ts.visitNode(node.attributes, visitor, ts.isJsxAttributes));
70150         }
70151         function shouldEmitEnumDeclaration(node) {
70152             return !ts.isEnumConst(node)
70153                 || compilerOptions.preserveConstEnums
70154                 || compilerOptions.isolatedModules;
70155         }
70156         function visitEnumDeclaration(node) {
70157             if (!shouldEmitEnumDeclaration(node)) {
70158                 return factory.createNotEmittedStatement(node);
70159             }
70160             var statements = [];
70161             var emitFlags = 2;
70162             var varAdded = addVarForEnumOrModuleDeclaration(statements, node);
70163             if (varAdded) {
70164                 if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) {
70165                     emitFlags |= 512;
70166                 }
70167             }
70168             var parameterName = getNamespaceParameterName(node);
70169             var containerName = getNamespaceContainerName(node);
70170             var exportName = ts.hasSyntacticModifier(node, 1)
70171                 ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true)
70172                 : factory.getLocalName(node, false, true);
70173             var moduleArg = factory.createLogicalOr(exportName, factory.createAssignment(exportName, factory.createObjectLiteralExpression()));
70174             if (hasNamespaceQualifiedExportName(node)) {
70175                 var localName = factory.getLocalName(node, false, true);
70176                 moduleArg = factory.createAssignment(localName, moduleArg);
70177             }
70178             var enumStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createFunctionExpression(undefined, undefined, undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, undefined, parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [moduleArg]));
70179             ts.setOriginalNode(enumStatement, node);
70180             if (varAdded) {
70181                 ts.setSyntheticLeadingComments(enumStatement, undefined);
70182                 ts.setSyntheticTrailingComments(enumStatement, undefined);
70183             }
70184             ts.setTextRange(enumStatement, node);
70185             ts.addEmitFlags(enumStatement, emitFlags);
70186             statements.push(enumStatement);
70187             statements.push(factory.createEndOfDeclarationMarker(node));
70188             return statements;
70189         }
70190         function transformEnumBody(node, localName) {
70191             var savedCurrentNamespaceLocalName = currentNamespaceContainerName;
70192             currentNamespaceContainerName = localName;
70193             var statements = [];
70194             startLexicalEnvironment();
70195             var members = ts.map(node.members, transformEnumMember);
70196             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
70197             ts.addRange(statements, members);
70198             currentNamespaceContainerName = savedCurrentNamespaceLocalName;
70199             return factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), node.members), true);
70200         }
70201         function transformEnumMember(member) {
70202             var name = getExpressionForPropertyName(member, false);
70203             var valueExpression = transformEnumMemberDeclarationValue(member);
70204             var innerAssignment = factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, name), valueExpression);
70205             var outerAssignment = valueExpression.kind === 10 ?
70206                 innerAssignment :
70207                 factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, innerAssignment), name);
70208             return ts.setTextRange(factory.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member);
70209         }
70210         function transformEnumMemberDeclarationValue(member) {
70211             var value = resolver.getConstantValue(member);
70212             if (value !== undefined) {
70213                 return typeof value === "string" ? factory.createStringLiteral(value) : factory.createNumericLiteral(value);
70214             }
70215             else {
70216                 enableSubstitutionForNonQualifiedEnumMembers();
70217                 if (member.initializer) {
70218                     return ts.visitNode(member.initializer, visitor, ts.isExpression);
70219                 }
70220                 else {
70221                     return factory.createVoidZero();
70222                 }
70223             }
70224         }
70225         function shouldEmitModuleDeclaration(nodeIn) {
70226             var node = ts.getParseTreeNode(nodeIn, ts.isModuleDeclaration);
70227             if (!node) {
70228                 return true;
70229             }
70230             return ts.isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules);
70231         }
70232         function hasNamespaceQualifiedExportName(node) {
70233             return isExportOfNamespace(node)
70234                 || (isExternalModuleExport(node)
70235                     && moduleKind !== ts.ModuleKind.ES2015
70236                     && moduleKind !== ts.ModuleKind.ES2020
70237                     && moduleKind !== ts.ModuleKind.ESNext
70238                     && moduleKind !== ts.ModuleKind.System);
70239         }
70240         function recordEmittedDeclarationInScope(node) {
70241             if (!currentScopeFirstDeclarationsOfName) {
70242                 currentScopeFirstDeclarationsOfName = new ts.Map();
70243             }
70244             var name = declaredNameInScope(node);
70245             if (!currentScopeFirstDeclarationsOfName.has(name)) {
70246                 currentScopeFirstDeclarationsOfName.set(name, node);
70247             }
70248         }
70249         function isFirstEmittedDeclarationInScope(node) {
70250             if (currentScopeFirstDeclarationsOfName) {
70251                 var name = declaredNameInScope(node);
70252                 return currentScopeFirstDeclarationsOfName.get(name) === node;
70253             }
70254             return true;
70255         }
70256         function declaredNameInScope(node) {
70257             ts.Debug.assertNode(node.name, ts.isIdentifier);
70258             return node.name.escapedText;
70259         }
70260         function addVarForEnumOrModuleDeclaration(statements, node) {
70261             var statement = factory.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.createVariableDeclarationList([
70262                 factory.createVariableDeclaration(factory.getLocalName(node, false, true))
70263             ], currentLexicalScope.kind === 297 ? 0 : 1));
70264             ts.setOriginalNode(statement, node);
70265             recordEmittedDeclarationInScope(node);
70266             if (isFirstEmittedDeclarationInScope(node)) {
70267                 if (node.kind === 255) {
70268                     ts.setSourceMapRange(statement.declarationList, node);
70269                 }
70270                 else {
70271                     ts.setSourceMapRange(statement, node);
70272                 }
70273                 ts.setCommentRange(statement, node);
70274                 ts.addEmitFlags(statement, 1024 | 4194304);
70275                 statements.push(statement);
70276                 return true;
70277             }
70278             else {
70279                 var mergeMarker = factory.createMergeDeclarationMarker(statement);
70280                 ts.setEmitFlags(mergeMarker, 1536 | 4194304);
70281                 statements.push(mergeMarker);
70282                 return false;
70283             }
70284         }
70285         function visitModuleDeclaration(node) {
70286             if (!shouldEmitModuleDeclaration(node)) {
70287                 return factory.createNotEmittedStatement(node);
70288             }
70289             ts.Debug.assertNode(node.name, ts.isIdentifier, "A TypeScript namespace should have an Identifier name.");
70290             enableSubstitutionForNamespaceExports();
70291             var statements = [];
70292             var emitFlags = 2;
70293             var varAdded = addVarForEnumOrModuleDeclaration(statements, node);
70294             if (varAdded) {
70295                 if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) {
70296                     emitFlags |= 512;
70297                 }
70298             }
70299             var parameterName = getNamespaceParameterName(node);
70300             var containerName = getNamespaceContainerName(node);
70301             var exportName = ts.hasSyntacticModifier(node, 1)
70302                 ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true)
70303                 : factory.getLocalName(node, false, true);
70304             var moduleArg = factory.createLogicalOr(exportName, factory.createAssignment(exportName, factory.createObjectLiteralExpression()));
70305             if (hasNamespaceQualifiedExportName(node)) {
70306                 var localName = factory.getLocalName(node, false, true);
70307                 moduleArg = factory.createAssignment(localName, moduleArg);
70308             }
70309             var moduleStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createFunctionExpression(undefined, undefined, undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, undefined, parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]));
70310             ts.setOriginalNode(moduleStatement, node);
70311             if (varAdded) {
70312                 ts.setSyntheticLeadingComments(moduleStatement, undefined);
70313                 ts.setSyntheticTrailingComments(moduleStatement, undefined);
70314             }
70315             ts.setTextRange(moduleStatement, node);
70316             ts.addEmitFlags(moduleStatement, emitFlags);
70317             statements.push(moduleStatement);
70318             statements.push(factory.createEndOfDeclarationMarker(node));
70319             return statements;
70320         }
70321         function transformModuleBody(node, namespaceLocalName) {
70322             var savedCurrentNamespaceContainerName = currentNamespaceContainerName;
70323             var savedCurrentNamespace = currentNamespace;
70324             var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName;
70325             currentNamespaceContainerName = namespaceLocalName;
70326             currentNamespace = node;
70327             currentScopeFirstDeclarationsOfName = undefined;
70328             var statements = [];
70329             startLexicalEnvironment();
70330             var statementsLocation;
70331             var blockLocation;
70332             if (node.body) {
70333                 if (node.body.kind === 257) {
70334                     saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); });
70335                     statementsLocation = node.body.statements;
70336                     blockLocation = node.body;
70337                 }
70338                 else {
70339                     var result = visitModuleDeclaration(node.body);
70340                     if (result) {
70341                         if (ts.isArray(result)) {
70342                             ts.addRange(statements, result);
70343                         }
70344                         else {
70345                             statements.push(result);
70346                         }
70347                     }
70348                     var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body;
70349                     statementsLocation = ts.moveRangePos(moduleBlock.statements, -1);
70350                 }
70351             }
70352             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
70353             currentNamespaceContainerName = savedCurrentNamespaceContainerName;
70354             currentNamespace = savedCurrentNamespace;
70355             currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName;
70356             var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), true);
70357             ts.setTextRange(block, blockLocation);
70358             if (!node.body || node.body.kind !== 257) {
70359                 ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536);
70360             }
70361             return block;
70362         }
70363         function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) {
70364             if (moduleDeclaration.body.kind === 256) {
70365                 var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body);
70366                 return recursiveInnerModule || moduleDeclaration.body;
70367             }
70368         }
70369         function visitImportDeclaration(node) {
70370             if (!node.importClause) {
70371                 return node;
70372             }
70373             if (node.importClause.isTypeOnly) {
70374                 return undefined;
70375             }
70376             var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause);
70377             return importClause ||
70378                 compilerOptions.importsNotUsedAsValues === 1 ||
70379                 compilerOptions.importsNotUsedAsValues === 2
70380                 ? factory.updateImportDeclaration(node, undefined, undefined, importClause, node.moduleSpecifier)
70381                 : undefined;
70382         }
70383         function visitImportClause(node) {
70384             if (node.isTypeOnly) {
70385                 return undefined;
70386             }
70387             var name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined;
70388             var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings);
70389             return (name || namedBindings) ? factory.updateImportClause(node, false, name, namedBindings) : undefined;
70390         }
70391         function visitNamedImportBindings(node) {
70392             if (node.kind === 263) {
70393                 return resolver.isReferencedAliasDeclaration(node) ? node : undefined;
70394             }
70395             else {
70396                 var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier);
70397                 return ts.some(elements) ? factory.updateNamedImports(node, elements) : undefined;
70398             }
70399         }
70400         function visitImportSpecifier(node) {
70401             return resolver.isReferencedAliasDeclaration(node) ? node : undefined;
70402         }
70403         function visitExportAssignment(node) {
70404             return resolver.isValueAliasDeclaration(node)
70405                 ? ts.visitEachChild(node, visitor, context)
70406                 : undefined;
70407         }
70408         function visitExportDeclaration(node) {
70409             if (node.isTypeOnly) {
70410                 return undefined;
70411             }
70412             if (!node.exportClause || ts.isNamespaceExport(node.exportClause)) {
70413                 return node;
70414             }
70415             if (!resolver.isValueAliasDeclaration(node)) {
70416                 return undefined;
70417             }
70418             var exportClause = ts.visitNode(node.exportClause, visitNamedExportBindings, ts.isNamedExportBindings);
70419             return exportClause
70420                 ? factory.updateExportDeclaration(node, undefined, undefined, node.isTypeOnly, exportClause, node.moduleSpecifier)
70421                 : undefined;
70422         }
70423         function visitNamedExports(node) {
70424             var elements = ts.visitNodes(node.elements, visitExportSpecifier, ts.isExportSpecifier);
70425             return ts.some(elements) ? factory.updateNamedExports(node, elements) : undefined;
70426         }
70427         function visitNamespaceExports(node) {
70428             return factory.updateNamespaceExport(node, ts.visitNode(node.name, visitor, ts.isIdentifier));
70429         }
70430         function visitNamedExportBindings(node) {
70431             return ts.isNamespaceExport(node) ? visitNamespaceExports(node) : visitNamedExports(node);
70432         }
70433         function visitExportSpecifier(node) {
70434             return resolver.isValueAliasDeclaration(node) ? node : undefined;
70435         }
70436         function shouldEmitImportEqualsDeclaration(node) {
70437             return resolver.isReferencedAliasDeclaration(node)
70438                 || (!ts.isExternalModule(currentSourceFile)
70439                     && resolver.isTopLevelValueImportEqualsWithEntityName(node));
70440         }
70441         function visitImportEqualsDeclaration(node) {
70442             if (ts.isExternalModuleImportEqualsDeclaration(node)) {
70443                 var isReferenced = resolver.isReferencedAliasDeclaration(node);
70444                 if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1) {
70445                     return ts.setOriginalNode(ts.setTextRange(factory.createImportDeclaration(undefined, undefined, undefined, node.moduleReference.expression), node), node);
70446                 }
70447                 return isReferenced ? ts.visitEachChild(node, visitor, context) : undefined;
70448             }
70449             if (!shouldEmitImportEqualsDeclaration(node)) {
70450                 return undefined;
70451             }
70452             var moduleReference = ts.createExpressionFromEntityName(factory, node.moduleReference);
70453             ts.setEmitFlags(moduleReference, 1536 | 2048);
70454             if (isNamedExternalModuleExport(node) || !isExportOfNamespace(node)) {
70455                 return ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.createVariableDeclarationList([
70456                     ts.setOriginalNode(factory.createVariableDeclaration(node.name, undefined, undefined, moduleReference), node)
70457                 ])), node), node);
70458             }
70459             else {
70460                 return ts.setOriginalNode(createNamespaceExport(node.name, moduleReference, node), node);
70461             }
70462         }
70463         function isExportOfNamespace(node) {
70464             return currentNamespace !== undefined && ts.hasSyntacticModifier(node, 1);
70465         }
70466         function isExternalModuleExport(node) {
70467             return currentNamespace === undefined && ts.hasSyntacticModifier(node, 1);
70468         }
70469         function isNamedExternalModuleExport(node) {
70470             return isExternalModuleExport(node)
70471                 && !ts.hasSyntacticModifier(node, 512);
70472         }
70473         function isDefaultExternalModuleExport(node) {
70474             return isExternalModuleExport(node)
70475                 && ts.hasSyntacticModifier(node, 512);
70476         }
70477         function expressionToStatement(expression) {
70478             return factory.createExpressionStatement(expression);
70479         }
70480         function addExportMemberAssignment(statements, node) {
70481             var expression = factory.createAssignment(factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true), factory.getLocalName(node));
70482             ts.setSourceMapRange(expression, ts.createRange(node.name ? node.name.pos : node.pos, node.end));
70483             var statement = factory.createExpressionStatement(expression);
70484             ts.setSourceMapRange(statement, ts.createRange(-1, node.end));
70485             statements.push(statement);
70486         }
70487         function createNamespaceExport(exportName, exportValue, location) {
70488             return ts.setTextRange(factory.createExpressionStatement(factory.createAssignment(factory.getNamespaceMemberName(currentNamespaceContainerName, exportName, false, true), exportValue)), location);
70489         }
70490         function createNamespaceExportExpression(exportName, exportValue, location) {
70491             return ts.setTextRange(factory.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location);
70492         }
70493         function getNamespaceMemberNameWithSourceMapsAndWithoutComments(name) {
70494             return factory.getNamespaceMemberName(currentNamespaceContainerName, name, false, true);
70495         }
70496         function getNamespaceParameterName(node) {
70497             var name = factory.getGeneratedNameForNode(node);
70498             ts.setSourceMapRange(name, node.name);
70499             return name;
70500         }
70501         function getNamespaceContainerName(node) {
70502             return factory.getGeneratedNameForNode(node);
70503         }
70504         function getClassAliasIfNeeded(node) {
70505             if (resolver.getNodeCheckFlags(node) & 16777216) {
70506                 enableSubstitutionForClassAliases();
70507                 var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default");
70508                 classAliases[ts.getOriginalNodeId(node)] = classAlias;
70509                 hoistVariableDeclaration(classAlias);
70510                 return classAlias;
70511             }
70512         }
70513         function getClassPrototype(node) {
70514             return factory.createPropertyAccessExpression(factory.getDeclarationName(node), "prototype");
70515         }
70516         function getClassMemberPrefix(node, member) {
70517             return ts.hasSyntacticModifier(member, 32)
70518                 ? factory.getDeclarationName(node)
70519                 : getClassPrototype(node);
70520         }
70521         function enableSubstitutionForNonQualifiedEnumMembers() {
70522             if ((enabledSubstitutions & 8) === 0) {
70523                 enabledSubstitutions |= 8;
70524                 context.enableSubstitution(78);
70525             }
70526         }
70527         function enableSubstitutionForClassAliases() {
70528             if ((enabledSubstitutions & 1) === 0) {
70529                 enabledSubstitutions |= 1;
70530                 context.enableSubstitution(78);
70531                 classAliases = [];
70532             }
70533         }
70534         function enableSubstitutionForNamespaceExports() {
70535             if ((enabledSubstitutions & 2) === 0) {
70536                 enabledSubstitutions |= 2;
70537                 context.enableSubstitution(78);
70538                 context.enableSubstitution(289);
70539                 context.enableEmitNotification(256);
70540             }
70541         }
70542         function isTransformedModuleDeclaration(node) {
70543             return ts.getOriginalNode(node).kind === 256;
70544         }
70545         function isTransformedEnumDeclaration(node) {
70546             return ts.getOriginalNode(node).kind === 255;
70547         }
70548         function onEmitNode(hint, node, emitCallback) {
70549             var savedApplicableSubstitutions = applicableSubstitutions;
70550             var savedCurrentSourceFile = currentSourceFile;
70551             if (ts.isSourceFile(node)) {
70552                 currentSourceFile = node;
70553             }
70554             if (enabledSubstitutions & 2 && isTransformedModuleDeclaration(node)) {
70555                 applicableSubstitutions |= 2;
70556             }
70557             if (enabledSubstitutions & 8 && isTransformedEnumDeclaration(node)) {
70558                 applicableSubstitutions |= 8;
70559             }
70560             previousOnEmitNode(hint, node, emitCallback);
70561             applicableSubstitutions = savedApplicableSubstitutions;
70562             currentSourceFile = savedCurrentSourceFile;
70563         }
70564         function onSubstituteNode(hint, node) {
70565             node = previousOnSubstituteNode(hint, node);
70566             if (hint === 1) {
70567                 return substituteExpression(node);
70568             }
70569             else if (ts.isShorthandPropertyAssignment(node)) {
70570                 return substituteShorthandPropertyAssignment(node);
70571             }
70572             return node;
70573         }
70574         function substituteShorthandPropertyAssignment(node) {
70575             if (enabledSubstitutions & 2) {
70576                 var name = node.name;
70577                 var exportedName = trySubstituteNamespaceExportedName(name);
70578                 if (exportedName) {
70579                     if (node.objectAssignmentInitializer) {
70580                         var initializer = factory.createAssignment(exportedName, node.objectAssignmentInitializer);
70581                         return ts.setTextRange(factory.createPropertyAssignment(name, initializer), node);
70582                     }
70583                     return ts.setTextRange(factory.createPropertyAssignment(name, exportedName), node);
70584                 }
70585             }
70586             return node;
70587         }
70588         function substituteExpression(node) {
70589             switch (node.kind) {
70590                 case 78:
70591                     return substituteExpressionIdentifier(node);
70592                 case 201:
70593                     return substitutePropertyAccessExpression(node);
70594                 case 202:
70595                     return substituteElementAccessExpression(node);
70596             }
70597             return node;
70598         }
70599         function substituteExpressionIdentifier(node) {
70600             return trySubstituteClassAlias(node)
70601                 || trySubstituteNamespaceExportedName(node)
70602                 || node;
70603         }
70604         function trySubstituteClassAlias(node) {
70605             if (enabledSubstitutions & 1) {
70606                 if (resolver.getNodeCheckFlags(node) & 33554432) {
70607                     var declaration = resolver.getReferencedValueDeclaration(node);
70608                     if (declaration) {
70609                         var classAlias = classAliases[declaration.id];
70610                         if (classAlias) {
70611                             var clone_1 = factory.cloneNode(classAlias);
70612                             ts.setSourceMapRange(clone_1, node);
70613                             ts.setCommentRange(clone_1, node);
70614                             return clone_1;
70615                         }
70616                     }
70617                 }
70618             }
70619             return undefined;
70620         }
70621         function trySubstituteNamespaceExportedName(node) {
70622             if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) {
70623                 var container = resolver.getReferencedExportContainer(node, false);
70624                 if (container && container.kind !== 297) {
70625                     var substitute = (applicableSubstitutions & 2 && container.kind === 256) ||
70626                         (applicableSubstitutions & 8 && container.kind === 255);
70627                     if (substitute) {
70628                         return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(container), node), node);
70629                     }
70630                 }
70631             }
70632             return undefined;
70633         }
70634         function substitutePropertyAccessExpression(node) {
70635             return substituteConstantValue(node);
70636         }
70637         function substituteElementAccessExpression(node) {
70638             return substituteConstantValue(node);
70639         }
70640         function substituteConstantValue(node) {
70641             var constantValue = tryGetConstEnumValue(node);
70642             if (constantValue !== undefined) {
70643                 ts.setConstantValue(node, constantValue);
70644                 var substitute = typeof constantValue === "string" ? factory.createStringLiteral(constantValue) : factory.createNumericLiteral(constantValue);
70645                 if (!compilerOptions.removeComments) {
70646                     var originalNode = ts.getOriginalNode(node, ts.isAccessExpression);
70647                     var propertyName = ts.isPropertyAccessExpression(originalNode)
70648                         ? ts.declarationNameToString(originalNode.name)
70649                         : ts.getTextOfNode(originalNode.argumentExpression);
70650                     ts.addSyntheticTrailingComment(substitute, 3, " " + propertyName + " ");
70651                 }
70652                 return substitute;
70653             }
70654             return node;
70655         }
70656         function tryGetConstEnumValue(node) {
70657             if (compilerOptions.isolatedModules) {
70658                 return undefined;
70659             }
70660             return ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) ? resolver.getConstantValue(node) : undefined;
70661         }
70662     }
70663     ts.transformTypeScript = transformTypeScript;
70664 })(ts || (ts = {}));
70665 var ts;
70666 (function (ts) {
70667     function transformClassFields(context) {
70668         var factory = context.factory, hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment;
70669         var resolver = context.getEmitResolver();
70670         var compilerOptions = context.getCompilerOptions();
70671         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
70672         var shouldTransformPrivateFields = languageVersion < 99;
70673         var previousOnSubstituteNode = context.onSubstituteNode;
70674         context.onSubstituteNode = onSubstituteNode;
70675         var enabledSubstitutions;
70676         var classAliases;
70677         var pendingExpressions;
70678         var pendingStatements;
70679         var privateIdentifierEnvironmentStack = [];
70680         var currentPrivateIdentifierEnvironment;
70681         return ts.chainBundle(context, transformSourceFile);
70682         function transformSourceFile(node) {
70683             var options = context.getCompilerOptions();
70684             if (node.isDeclarationFile
70685                 || options.useDefineForClassFields && options.target === 99) {
70686                 return node;
70687             }
70688             var visited = ts.visitEachChild(node, visitor, context);
70689             ts.addEmitHelpers(visited, context.readEmitHelpers());
70690             return visited;
70691         }
70692         function visitor(node) {
70693             if (!(node.transformFlags & 4194304))
70694                 return node;
70695             switch (node.kind) {
70696                 case 221:
70697                 case 252:
70698                     return visitClassLike(node);
70699                 case 163:
70700                     return visitPropertyDeclaration(node);
70701                 case 232:
70702                     return visitVariableStatement(node);
70703                 case 158:
70704                     return visitComputedPropertyName(node);
70705                 case 201:
70706                     return visitPropertyAccessExpression(node);
70707                 case 214:
70708                     return visitPrefixUnaryExpression(node);
70709                 case 215:
70710                     return visitPostfixUnaryExpression(node, false);
70711                 case 203:
70712                     return visitCallExpression(node);
70713                 case 216:
70714                     return visitBinaryExpression(node);
70715                 case 79:
70716                     return visitPrivateIdentifier(node);
70717                 case 233:
70718                     return visitExpressionStatement(node);
70719                 case 237:
70720                     return visitForStatement(node);
70721                 case 205:
70722                     return visitTaggedTemplateExpression(node);
70723             }
70724             return ts.visitEachChild(node, visitor, context);
70725         }
70726         function visitorDestructuringTarget(node) {
70727             switch (node.kind) {
70728                 case 200:
70729                 case 199:
70730                     return visitAssignmentPattern(node);
70731                 default:
70732                     return visitor(node);
70733             }
70734         }
70735         function visitPrivateIdentifier(node) {
70736             if (!shouldTransformPrivateFields) {
70737                 return node;
70738             }
70739             return ts.setOriginalNode(factory.createIdentifier(""), node);
70740         }
70741         function classElementVisitor(node) {
70742             switch (node.kind) {
70743                 case 166:
70744                     return undefined;
70745                 case 167:
70746                 case 168:
70747                 case 165:
70748                     return ts.visitEachChild(node, classElementVisitor, context);
70749                 case 163:
70750                     return visitPropertyDeclaration(node);
70751                 case 158:
70752                     return visitComputedPropertyName(node);
70753                 case 229:
70754                     return node;
70755                 default:
70756                     return visitor(node);
70757             }
70758         }
70759         function visitVariableStatement(node) {
70760             var savedPendingStatements = pendingStatements;
70761             pendingStatements = [];
70762             var visitedNode = ts.visitEachChild(node, visitor, context);
70763             var statement = ts.some(pendingStatements) ? __spreadArrays([visitedNode], pendingStatements) :
70764                 visitedNode;
70765             pendingStatements = savedPendingStatements;
70766             return statement;
70767         }
70768         function visitComputedPropertyName(name) {
70769             var node = ts.visitEachChild(name, visitor, context);
70770             if (ts.some(pendingExpressions)) {
70771                 var expressions = pendingExpressions;
70772                 expressions.push(name.expression);
70773                 pendingExpressions = [];
70774                 node = factory.updateComputedPropertyName(node, factory.inlineExpressions(expressions));
70775             }
70776             return node;
70777         }
70778         function visitPropertyDeclaration(node) {
70779             ts.Debug.assert(!ts.some(node.decorators));
70780             if (!shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) {
70781                 return factory.updatePropertyDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, undefined, undefined, undefined);
70782             }
70783             var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || !!context.getCompilerOptions().useDefineForClassFields);
70784             if (expr && !ts.isSimpleInlineableExpression(expr)) {
70785                 getPendingExpressions().push(expr);
70786             }
70787             return undefined;
70788         }
70789         function createPrivateIdentifierAccess(info, receiver) {
70790             receiver = ts.visitNode(receiver, visitor, ts.isExpression);
70791             switch (info.placement) {
70792                 case 0:
70793                     return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(ts.nodeIsSynthesized(receiver) ? receiver : factory.cloneNode(receiver), info.weakMapName);
70794                 default: return ts.Debug.fail("Unexpected private identifier placement");
70795             }
70796         }
70797         function visitPropertyAccessExpression(node) {
70798             if (shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) {
70799                 var privateIdentifierInfo = accessPrivateIdentifier(node.name);
70800                 if (privateIdentifierInfo) {
70801                     return ts.setOriginalNode(createPrivateIdentifierAccess(privateIdentifierInfo, node.expression), node);
70802                 }
70803             }
70804             return ts.visitEachChild(node, visitor, context);
70805         }
70806         function visitPrefixUnaryExpression(node) {
70807             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) {
70808                 var operator = node.operator === 45 ?
70809                     39 : node.operator === 46 ?
70810                     40 : undefined;
70811                 var info = void 0;
70812                 if (operator && (info = accessPrivateIdentifier(node.operand.name))) {
70813                     var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression);
70814                     var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
70815                     var existingValue = factory.createPrefixUnaryExpression(39, createPrivateIdentifierAccess(info, readExpression));
70816                     return ts.setOriginalNode(createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(existingValue, operator, factory.createNumericLiteral(1)), 62), node);
70817                 }
70818             }
70819             return ts.visitEachChild(node, visitor, context);
70820         }
70821         function visitPostfixUnaryExpression(node, valueIsDiscarded) {
70822             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) {
70823                 var operator = node.operator === 45 ?
70824                     39 : node.operator === 46 ?
70825                     40 : undefined;
70826                 var info = void 0;
70827                 if (operator && (info = accessPrivateIdentifier(node.operand.name))) {
70828                     var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression);
70829                     var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
70830                     var existingValue = factory.createPrefixUnaryExpression(39, createPrivateIdentifierAccess(info, readExpression));
70831                     var returnValue = valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration);
70832                     return ts.setOriginalNode(factory.inlineExpressions(ts.compact([
70833                         createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(returnValue ? factory.createAssignment(returnValue, existingValue) : existingValue, operator, factory.createNumericLiteral(1)), 62),
70834                         returnValue
70835                     ])), node);
70836                 }
70837             }
70838             return ts.visitEachChild(node, visitor, context);
70839         }
70840         function visitForStatement(node) {
70841             if (node.incrementor && ts.isPostfixUnaryExpression(node.incrementor)) {
70842                 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));
70843             }
70844             return ts.visitEachChild(node, visitor, context);
70845         }
70846         function visitExpressionStatement(node) {
70847             if (ts.isPostfixUnaryExpression(node.expression)) {
70848                 return factory.updateExpressionStatement(node, visitPostfixUnaryExpression(node.expression, true));
70849             }
70850             return ts.visitEachChild(node, visitor, context);
70851         }
70852         function createCopiableReceiverExpr(receiver) {
70853             var clone = ts.nodeIsSynthesized(receiver) ? receiver : factory.cloneNode(receiver);
70854             if (ts.isSimpleInlineableExpression(receiver)) {
70855                 return { readExpression: clone, initializeExpression: undefined };
70856             }
70857             var readExpression = factory.createTempVariable(hoistVariableDeclaration);
70858             var initializeExpression = factory.createAssignment(readExpression, clone);
70859             return { readExpression: readExpression, initializeExpression: initializeExpression };
70860         }
70861         function visitCallExpression(node) {
70862             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.expression)) {
70863                 var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target;
70864                 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)));
70865             }
70866             return ts.visitEachChild(node, visitor, context);
70867         }
70868         function visitTaggedTemplateExpression(node) {
70869             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.tag)) {
70870                 var _a = factory.createCallBinding(node.tag, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target;
70871                 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));
70872             }
70873             return ts.visitEachChild(node, visitor, context);
70874         }
70875         function visitBinaryExpression(node) {
70876             if (shouldTransformPrivateFields) {
70877                 if (ts.isDestructuringAssignment(node)) {
70878                     var savedPendingExpressions = pendingExpressions;
70879                     pendingExpressions = undefined;
70880                     node = factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorDestructuringTarget), node.operatorToken, ts.visitNode(node.right, visitor));
70881                     var expr = ts.some(pendingExpressions) ?
70882                         factory.inlineExpressions(ts.compact(__spreadArrays(pendingExpressions, [node]))) :
70883                         node;
70884                     pendingExpressions = savedPendingExpressions;
70885                     return expr;
70886                 }
70887                 if (ts.isAssignmentExpression(node) && ts.isPrivateIdentifierPropertyAccessExpression(node.left)) {
70888                     var info = accessPrivateIdentifier(node.left.name);
70889                     if (info) {
70890                         return ts.setOriginalNode(createPrivateIdentifierAssignment(info, node.left.expression, node.right, node.operatorToken.kind), node);
70891                     }
70892                 }
70893             }
70894             return ts.visitEachChild(node, visitor, context);
70895         }
70896         function createPrivateIdentifierAssignment(info, receiver, right, operator) {
70897             switch (info.placement) {
70898                 case 0: {
70899                     return createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator);
70900                 }
70901                 default: return ts.Debug.fail("Unexpected private identifier placement");
70902             }
70903         }
70904         function createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator) {
70905             receiver = ts.visitNode(receiver, visitor, ts.isExpression);
70906             right = ts.visitNode(right, visitor, ts.isExpression);
70907             if (ts.isCompoundAssignment(operator)) {
70908                 var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
70909                 return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(initializeExpression || readExpression, info.weakMapName, factory.createBinaryExpression(context.getEmitHelperFactory().createClassPrivateFieldGetHelper(readExpression, info.weakMapName), ts.getNonAssignmentOperatorForCompoundAssignment(operator), right));
70910             }
70911             else {
70912                 return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.weakMapName, right);
70913             }
70914         }
70915         function visitClassLike(node) {
70916             var savedPendingExpressions = pendingExpressions;
70917             pendingExpressions = undefined;
70918             if (shouldTransformPrivateFields) {
70919                 startPrivateIdentifierEnvironment();
70920             }
70921             var result = ts.isClassDeclaration(node) ?
70922                 visitClassDeclaration(node) :
70923                 visitClassExpression(node);
70924             if (shouldTransformPrivateFields) {
70925                 endPrivateIdentifierEnvironment();
70926             }
70927             pendingExpressions = savedPendingExpressions;
70928             return result;
70929         }
70930         function doesClassElementNeedTransform(node) {
70931             return ts.isPropertyDeclaration(node) || (shouldTransformPrivateFields && node.name && ts.isPrivateIdentifier(node.name));
70932         }
70933         function visitClassDeclaration(node) {
70934             if (!ts.forEach(node.members, doesClassElementNeedTransform)) {
70935                 return ts.visitEachChild(node, visitor, context);
70936             }
70937             var extendsClauseElement = ts.getEffectiveBaseTypeNode(node);
70938             var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103);
70939             var statements = [
70940                 factory.updateClassDeclaration(node, undefined, node.modifiers, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass))
70941             ];
70942             if (ts.some(pendingExpressions)) {
70943                 statements.push(factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions)));
70944             }
70945             var staticProperties = ts.getProperties(node, true, true);
70946             if (ts.some(staticProperties)) {
70947                 addPropertyStatements(statements, staticProperties, factory.getInternalName(node));
70948             }
70949             return statements;
70950         }
70951         function visitClassExpression(node) {
70952             if (!ts.forEach(node.members, doesClassElementNeedTransform)) {
70953                 return ts.visitEachChild(node, visitor, context);
70954             }
70955             var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node));
70956             var staticProperties = ts.getProperties(node, true, true);
70957             var extendsClauseElement = ts.getEffectiveBaseTypeNode(node);
70958             var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103);
70959             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));
70960             if (ts.some(staticProperties) || ts.some(pendingExpressions)) {
70961                 if (isDecoratedClassDeclaration) {
70962                     ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration.");
70963                     if (pendingStatements && pendingExpressions && ts.some(pendingExpressions)) {
70964                         pendingStatements.push(factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions)));
70965                     }
70966                     if (pendingStatements && ts.some(staticProperties)) {
70967                         addPropertyStatements(pendingStatements, staticProperties, factory.getInternalName(node));
70968                     }
70969                     return classExpression;
70970                 }
70971                 else {
70972                     var expressions = [];
70973                     var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216;
70974                     var temp = factory.createTempVariable(hoistVariableDeclaration, !!isClassWithConstructorReference);
70975                     if (isClassWithConstructorReference) {
70976                         enableSubstitutionForClassAliases();
70977                         var alias = factory.cloneNode(temp);
70978                         alias.autoGenerateFlags &= ~8;
70979                         classAliases[ts.getOriginalNodeId(node)] = alias;
70980                     }
70981                     ts.setEmitFlags(classExpression, 65536 | ts.getEmitFlags(classExpression));
70982                     expressions.push(ts.startOnNewLine(factory.createAssignment(temp, classExpression)));
70983                     ts.addRange(expressions, ts.map(pendingExpressions, ts.startOnNewLine));
70984                     ts.addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp));
70985                     expressions.push(ts.startOnNewLine(temp));
70986                     return factory.inlineExpressions(expressions);
70987                 }
70988             }
70989             return classExpression;
70990         }
70991         function transformClassMembers(node, isDerivedClass) {
70992             if (shouldTransformPrivateFields) {
70993                 for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
70994                     var member = _a[_i];
70995                     if (ts.isPrivateIdentifierPropertyDeclaration(member)) {
70996                         addPrivateIdentifierToEnvironment(member.name);
70997                     }
70998                 }
70999             }
71000             var members = [];
71001             var constructor = transformConstructor(node, isDerivedClass);
71002             if (constructor) {
71003                 members.push(constructor);
71004             }
71005             ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement));
71006             return ts.setTextRange(factory.createNodeArray(members), node.members);
71007         }
71008         function isPropertyDeclarationThatRequiresConstructorStatement(member) {
71009             if (!ts.isPropertyDeclaration(member) || ts.hasStaticModifier(member)) {
71010                 return false;
71011             }
71012             if (context.getCompilerOptions().useDefineForClassFields) {
71013                 return languageVersion < 99;
71014             }
71015             return ts.isInitializedProperty(member) || shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyDeclaration(member);
71016         }
71017         function transformConstructor(node, isDerivedClass) {
71018             var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration);
71019             var properties = node.members.filter(isPropertyDeclarationThatRequiresConstructorStatement);
71020             if (!ts.some(properties)) {
71021                 return constructor;
71022             }
71023             var parameters = ts.visitParameterList(constructor ? constructor.parameters : undefined, visitor, context);
71024             var body = transformConstructorBody(node, constructor, isDerivedClass);
71025             if (!body) {
71026                 return undefined;
71027             }
71028             return ts.startOnNewLine(ts.setOriginalNode(ts.setTextRange(factory.createConstructorDeclaration(undefined, undefined, parameters !== null && parameters !== void 0 ? parameters : [], body), constructor || node), constructor));
71029         }
71030         function transformConstructorBody(node, constructor, isDerivedClass) {
71031             var useDefineForClassFields = context.getCompilerOptions().useDefineForClassFields;
71032             var properties = ts.getProperties(node, false, false);
71033             if (!useDefineForClassFields) {
71034                 properties = ts.filter(properties, function (property) { return !!property.initializer || ts.isPrivateIdentifier(property.name); });
71035             }
71036             if (!constructor && !ts.some(properties)) {
71037                 return ts.visitFunctionBody(undefined, visitor, context);
71038             }
71039             resumeLexicalEnvironment();
71040             var indexOfFirstStatement = 0;
71041             var statements = [];
71042             if (!constructor && isDerivedClass) {
71043                 statements.push(factory.createExpressionStatement(factory.createCallExpression(factory.createSuper(), undefined, [factory.createSpreadElement(factory.createIdentifier("arguments"))])));
71044             }
71045             if (constructor) {
71046                 indexOfFirstStatement = ts.addPrologueDirectivesAndInitialSuperCall(factory, constructor, statements, visitor);
71047             }
71048             if (constructor === null || constructor === void 0 ? void 0 : constructor.body) {
71049                 var afterParameterProperties = ts.findIndex(constructor.body.statements, function (s) { return !ts.isParameterPropertyDeclaration(ts.getOriginalNode(s), constructor); }, indexOfFirstStatement);
71050                 if (afterParameterProperties === -1) {
71051                     afterParameterProperties = constructor.body.statements.length;
71052                 }
71053                 if (afterParameterProperties > indexOfFirstStatement) {
71054                     if (!useDefineForClassFields) {
71055                         ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement, afterParameterProperties - indexOfFirstStatement));
71056                     }
71057                     indexOfFirstStatement = afterParameterProperties;
71058                 }
71059             }
71060             addPropertyStatements(statements, properties, factory.createThis());
71061             if (constructor) {
71062                 ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement));
71063             }
71064             statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
71065             return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true), constructor ? constructor.body : undefined);
71066         }
71067         function addPropertyStatements(statements, properties, receiver) {
71068             for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
71069                 var property = properties_7[_i];
71070                 var expression = transformProperty(property, receiver);
71071                 if (!expression) {
71072                     continue;
71073                 }
71074                 var statement = factory.createExpressionStatement(expression);
71075                 ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
71076                 ts.setCommentRange(statement, property);
71077                 ts.setOriginalNode(statement, property);
71078                 statements.push(statement);
71079             }
71080         }
71081         function generateInitializedPropertyExpressions(properties, receiver) {
71082             var expressions = [];
71083             for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) {
71084                 var property = properties_8[_i];
71085                 var expression = transformProperty(property, receiver);
71086                 if (!expression) {
71087                     continue;
71088                 }
71089                 ts.startOnNewLine(expression);
71090                 ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property));
71091                 ts.setCommentRange(expression, property);
71092                 ts.setOriginalNode(expression, property);
71093                 expressions.push(expression);
71094             }
71095             return expressions;
71096         }
71097         function transformProperty(property, receiver) {
71098             var _a;
71099             var emitAssignment = !context.getCompilerOptions().useDefineForClassFields;
71100             var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression)
71101                 ? factory.updateComputedPropertyName(property.name, factory.getGeneratedNameForNode(property.name))
71102                 : property.name;
71103             if (shouldTransformPrivateFields && ts.isPrivateIdentifier(propertyName)) {
71104                 var privateIdentifierInfo = accessPrivateIdentifier(propertyName);
71105                 if (privateIdentifierInfo) {
71106                     switch (privateIdentifierInfo.placement) {
71107                         case 0: {
71108                             return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.weakMapName);
71109                         }
71110                     }
71111                 }
71112                 else {
71113                     ts.Debug.fail("Undeclared private name for property declaration.");
71114                 }
71115             }
71116             if (ts.isPrivateIdentifier(propertyName) && !property.initializer) {
71117                 return undefined;
71118             }
71119             if (ts.isPrivateIdentifier(propertyName) && !property.initializer) {
71120                 return undefined;
71121             }
71122             var propertyOriginalNode = ts.getOriginalNode(property);
71123             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
71124                 : factory.createVoidZero();
71125             if (emitAssignment || ts.isPrivateIdentifier(propertyName)) {
71126                 var memberAccess = ts.createMemberAccessForPropertyName(factory, receiver, propertyName, propertyName);
71127                 return factory.createAssignment(memberAccess, initializer);
71128             }
71129             else {
71130                 var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression
71131                     : ts.isIdentifier(propertyName) ? factory.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText))
71132                         : propertyName;
71133                 var descriptor = factory.createPropertyDescriptor({ value: initializer, configurable: true, writable: true, enumerable: true });
71134                 return factory.createObjectDefinePropertyCall(receiver, name, descriptor);
71135             }
71136         }
71137         function enableSubstitutionForClassAliases() {
71138             if ((enabledSubstitutions & 1) === 0) {
71139                 enabledSubstitutions |= 1;
71140                 context.enableSubstitution(78);
71141                 classAliases = [];
71142             }
71143         }
71144         function onSubstituteNode(hint, node) {
71145             node = previousOnSubstituteNode(hint, node);
71146             if (hint === 1) {
71147                 return substituteExpression(node);
71148             }
71149             return node;
71150         }
71151         function substituteExpression(node) {
71152             switch (node.kind) {
71153                 case 78:
71154                     return substituteExpressionIdentifier(node);
71155             }
71156             return node;
71157         }
71158         function substituteExpressionIdentifier(node) {
71159             return trySubstituteClassAlias(node) || node;
71160         }
71161         function trySubstituteClassAlias(node) {
71162             if (enabledSubstitutions & 1) {
71163                 if (resolver.getNodeCheckFlags(node) & 33554432) {
71164                     var declaration = resolver.getReferencedValueDeclaration(node);
71165                     if (declaration) {
71166                         var classAlias = classAliases[declaration.id];
71167                         if (classAlias) {
71168                             var clone_2 = factory.cloneNode(classAlias);
71169                             ts.setSourceMapRange(clone_2, node);
71170                             ts.setCommentRange(clone_2, node);
71171                             return clone_2;
71172                         }
71173                     }
71174                 }
71175             }
71176             return undefined;
71177         }
71178         function getPropertyNameExpressionIfNeeded(name, shouldHoist) {
71179             if (ts.isComputedPropertyName(name)) {
71180                 var expression = ts.visitNode(name.expression, visitor, ts.isExpression);
71181                 var innerExpression = ts.skipPartiallyEmittedExpressions(expression);
71182                 var inlinable = ts.isSimpleInlineableExpression(innerExpression);
71183                 var alreadyTransformed = ts.isAssignmentExpression(innerExpression) && ts.isGeneratedIdentifier(innerExpression.left);
71184                 if (!alreadyTransformed && !inlinable && shouldHoist) {
71185                     var generatedName = factory.getGeneratedNameForNode(name);
71186                     hoistVariableDeclaration(generatedName);
71187                     return factory.createAssignment(generatedName, expression);
71188                 }
71189                 return (inlinable || ts.isIdentifier(innerExpression)) ? undefined : expression;
71190             }
71191         }
71192         function startPrivateIdentifierEnvironment() {
71193             privateIdentifierEnvironmentStack.push(currentPrivateIdentifierEnvironment);
71194             currentPrivateIdentifierEnvironment = undefined;
71195         }
71196         function endPrivateIdentifierEnvironment() {
71197             currentPrivateIdentifierEnvironment = privateIdentifierEnvironmentStack.pop();
71198         }
71199         function getPrivateIdentifierEnvironment() {
71200             return currentPrivateIdentifierEnvironment || (currentPrivateIdentifierEnvironment = new ts.Map());
71201         }
71202         function getPendingExpressions() {
71203             return pendingExpressions || (pendingExpressions = []);
71204         }
71205         function addPrivateIdentifierToEnvironment(name) {
71206             var text = ts.getTextOfPropertyName(name);
71207             var weakMapName = factory.createUniqueName("_" + text.substring(1), 16 | 8);
71208             hoistVariableDeclaration(weakMapName);
71209             getPrivateIdentifierEnvironment().set(name.escapedText, { placement: 0, weakMapName: weakMapName });
71210             getPendingExpressions().push(factory.createAssignment(weakMapName, factory.createNewExpression(factory.createIdentifier("WeakMap"), undefined, [])));
71211         }
71212         function accessPrivateIdentifier(name) {
71213             if (currentPrivateIdentifierEnvironment) {
71214                 var info = currentPrivateIdentifierEnvironment.get(name.escapedText);
71215                 if (info) {
71216                     return info;
71217                 }
71218             }
71219             for (var i = privateIdentifierEnvironmentStack.length - 1; i >= 0; --i) {
71220                 var env = privateIdentifierEnvironmentStack[i];
71221                 if (!env) {
71222                     continue;
71223                 }
71224                 var info = env.get(name.escapedText);
71225                 if (info) {
71226                     return info;
71227                 }
71228             }
71229             return undefined;
71230         }
71231         function wrapPrivateIdentifierForDestructuringTarget(node) {
71232             var parameter = factory.getGeneratedNameForNode(node);
71233             var info = accessPrivateIdentifier(node.name);
71234             if (!info) {
71235                 return ts.visitEachChild(node, visitor, context);
71236             }
71237             var receiver = node.expression;
71238             if (ts.isThisProperty(node) || ts.isSuperProperty(node) || !ts.isSimpleCopiableExpression(node.expression)) {
71239                 receiver = factory.createTempVariable(hoistVariableDeclaration, true);
71240                 getPendingExpressions().push(factory.createBinaryExpression(receiver, 62, node.expression));
71241             }
71242             return factory.createPropertyAccessExpression(factory.createParenthesizedExpression(factory.createObjectLiteralExpression([
71243                 factory.createSetAccessorDeclaration(undefined, undefined, "value", [factory.createParameterDeclaration(undefined, undefined, undefined, parameter, undefined, undefined, undefined)], factory.createBlock([factory.createExpressionStatement(createPrivateIdentifierAssignment(info, receiver, parameter, 62))]))
71244             ])), "value");
71245         }
71246         function visitArrayAssignmentTarget(node) {
71247             var target = ts.getTargetOfBindingOrAssignmentElement(node);
71248             if (target && ts.isPrivateIdentifierPropertyAccessExpression(target)) {
71249                 var wrapped = wrapPrivateIdentifierForDestructuringTarget(target);
71250                 if (ts.isAssignmentExpression(node)) {
71251                     return factory.updateBinaryExpression(node, wrapped, node.operatorToken, ts.visitNode(node.right, visitor, ts.isExpression));
71252                 }
71253                 else if (ts.isSpreadElement(node)) {
71254                     return factory.updateSpreadElement(node, wrapped);
71255                 }
71256                 else {
71257                     return wrapped;
71258                 }
71259             }
71260             return ts.visitNode(node, visitorDestructuringTarget);
71261         }
71262         function visitObjectAssignmentTarget(node) {
71263             if (ts.isPropertyAssignment(node)) {
71264                 var target = ts.getTargetOfBindingOrAssignmentElement(node);
71265                 if (target && ts.isPrivateIdentifierPropertyAccessExpression(target)) {
71266                     var initializer = ts.getInitializerOfBindingOrAssignmentElement(node);
71267                     var wrapped = wrapPrivateIdentifierForDestructuringTarget(target);
71268                     return factory.updatePropertyAssignment(node, ts.visitNode(node.name, visitor), initializer ? factory.createAssignment(wrapped, ts.visitNode(initializer, visitor)) : wrapped);
71269                 }
71270                 return factory.updatePropertyAssignment(node, ts.visitNode(node.name, visitor), ts.visitNode(node.initializer, visitorDestructuringTarget));
71271             }
71272             return ts.visitNode(node, visitor);
71273         }
71274         function visitAssignmentPattern(node) {
71275             if (ts.isArrayLiteralExpression(node)) {
71276                 return factory.updateArrayLiteralExpression(node, ts.visitNodes(node.elements, visitArrayAssignmentTarget, ts.isExpression));
71277             }
71278             else {
71279                 return factory.updateObjectLiteralExpression(node, ts.visitNodes(node.properties, visitObjectAssignmentTarget, ts.isObjectLiteralElementLike));
71280             }
71281         }
71282     }
71283     ts.transformClassFields = transformClassFields;
71284     function createPrivateInstanceFieldInitializer(receiver, initializer, weakMapName) {
71285         return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(weakMapName, "set"), undefined, [receiver, initializer || ts.factory.createVoidZero()]);
71286     }
71287 })(ts || (ts = {}));
71288 var ts;
71289 (function (ts) {
71290     function transformES2017(context) {
71291         var factory = context.factory, emitHelpers = context.getEmitHelperFactory, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
71292         var resolver = context.getEmitResolver();
71293         var compilerOptions = context.getCompilerOptions();
71294         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
71295         var enabledSubstitutions;
71296         var enclosingSuperContainerFlags = 0;
71297         var enclosingFunctionParameterNames;
71298         var capturedSuperProperties;
71299         var hasSuperElementAccess;
71300         var substitutedSuperAccessors = [];
71301         var contextFlags = 0;
71302         var previousOnEmitNode = context.onEmitNode;
71303         var previousOnSubstituteNode = context.onSubstituteNode;
71304         context.onEmitNode = onEmitNode;
71305         context.onSubstituteNode = onSubstituteNode;
71306         return ts.chainBundle(context, transformSourceFile);
71307         function transformSourceFile(node) {
71308             if (node.isDeclarationFile) {
71309                 return node;
71310             }
71311             setContextFlag(1, false);
71312             setContextFlag(2, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions));
71313             var visited = ts.visitEachChild(node, visitor, context);
71314             ts.addEmitHelpers(visited, context.readEmitHelpers());
71315             return visited;
71316         }
71317         function setContextFlag(flag, val) {
71318             contextFlags = val ? contextFlags | flag : contextFlags & ~flag;
71319         }
71320         function inContext(flags) {
71321             return (contextFlags & flags) !== 0;
71322         }
71323         function inTopLevelContext() {
71324             return !inContext(1);
71325         }
71326         function inHasLexicalThisContext() {
71327             return inContext(2);
71328         }
71329         function doWithContext(flags, cb, value) {
71330             var contextFlagsToSet = flags & ~contextFlags;
71331             if (contextFlagsToSet) {
71332                 setContextFlag(contextFlagsToSet, true);
71333                 var result = cb(value);
71334                 setContextFlag(contextFlagsToSet, false);
71335                 return result;
71336             }
71337             return cb(value);
71338         }
71339         function visitDefault(node) {
71340             return ts.visitEachChild(node, visitor, context);
71341         }
71342         function visitor(node) {
71343             if ((node.transformFlags & 64) === 0) {
71344                 return node;
71345             }
71346             switch (node.kind) {
71347                 case 129:
71348                     return undefined;
71349                 case 213:
71350                     return visitAwaitExpression(node);
71351                 case 165:
71352                     return doWithContext(1 | 2, visitMethodDeclaration, node);
71353                 case 251:
71354                     return doWithContext(1 | 2, visitFunctionDeclaration, node);
71355                 case 208:
71356                     return doWithContext(1 | 2, visitFunctionExpression, node);
71357                 case 209:
71358                     return doWithContext(1, visitArrowFunction, node);
71359                 case 201:
71360                     if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 105) {
71361                         capturedSuperProperties.add(node.name.escapedText);
71362                     }
71363                     return ts.visitEachChild(node, visitor, context);
71364                 case 202:
71365                     if (capturedSuperProperties && node.expression.kind === 105) {
71366                         hasSuperElementAccess = true;
71367                     }
71368                     return ts.visitEachChild(node, visitor, context);
71369                 case 167:
71370                 case 168:
71371                 case 166:
71372                 case 252:
71373                 case 221:
71374                     return doWithContext(1 | 2, visitDefault, node);
71375                 default:
71376                     return ts.visitEachChild(node, visitor, context);
71377             }
71378         }
71379         function asyncBodyVisitor(node) {
71380             if (ts.isNodeWithPossibleHoistedDeclaration(node)) {
71381                 switch (node.kind) {
71382                     case 232:
71383                         return visitVariableStatementInAsyncBody(node);
71384                     case 237:
71385                         return visitForStatementInAsyncBody(node);
71386                     case 238:
71387                         return visitForInStatementInAsyncBody(node);
71388                     case 239:
71389                         return visitForOfStatementInAsyncBody(node);
71390                     case 287:
71391                         return visitCatchClauseInAsyncBody(node);
71392                     case 230:
71393                     case 244:
71394                     case 258:
71395                     case 284:
71396                     case 285:
71397                     case 247:
71398                     case 235:
71399                     case 236:
71400                     case 234:
71401                     case 243:
71402                     case 245:
71403                         return ts.visitEachChild(node, asyncBodyVisitor, context);
71404                     default:
71405                         return ts.Debug.assertNever(node, "Unhandled node.");
71406                 }
71407             }
71408             return visitor(node);
71409         }
71410         function visitCatchClauseInAsyncBody(node) {
71411             var catchClauseNames = new ts.Set();
71412             recordDeclarationName(node.variableDeclaration, catchClauseNames);
71413             var catchClauseUnshadowedNames;
71414             catchClauseNames.forEach(function (_, escapedName) {
71415                 if (enclosingFunctionParameterNames.has(escapedName)) {
71416                     if (!catchClauseUnshadowedNames) {
71417                         catchClauseUnshadowedNames = new ts.Set(enclosingFunctionParameterNames);
71418                     }
71419                     catchClauseUnshadowedNames.delete(escapedName);
71420                 }
71421             });
71422             if (catchClauseUnshadowedNames) {
71423                 var savedEnclosingFunctionParameterNames = enclosingFunctionParameterNames;
71424                 enclosingFunctionParameterNames = catchClauseUnshadowedNames;
71425                 var result = ts.visitEachChild(node, asyncBodyVisitor, context);
71426                 enclosingFunctionParameterNames = savedEnclosingFunctionParameterNames;
71427                 return result;
71428             }
71429             else {
71430                 return ts.visitEachChild(node, asyncBodyVisitor, context);
71431             }
71432         }
71433         function visitVariableStatementInAsyncBody(node) {
71434             if (isVariableDeclarationListWithCollidingName(node.declarationList)) {
71435                 var expression = visitVariableDeclarationListWithCollidingNames(node.declarationList, false);
71436                 return expression ? factory.createExpressionStatement(expression) : undefined;
71437             }
71438             return ts.visitEachChild(node, visitor, context);
71439         }
71440         function visitForInStatementInAsyncBody(node) {
71441             return factory.updateForInStatement(node, isVariableDeclarationListWithCollidingName(node.initializer)
71442                 ? visitVariableDeclarationListWithCollidingNames(node.initializer, true)
71443                 : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock));
71444         }
71445         function visitForOfStatementInAsyncBody(node) {
71446             return factory.updateForOfStatement(node, ts.visitNode(node.awaitModifier, visitor, ts.isToken), isVariableDeclarationListWithCollidingName(node.initializer)
71447                 ? visitVariableDeclarationListWithCollidingNames(node.initializer, true)
71448                 : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock));
71449         }
71450         function visitForStatementInAsyncBody(node) {
71451             var initializer = node.initializer;
71452             return factory.updateForStatement(node, isVariableDeclarationListWithCollidingName(initializer)
71453                 ? visitVariableDeclarationListWithCollidingNames(initializer, false)
71454                 : 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));
71455         }
71456         function visitAwaitExpression(node) {
71457             if (inTopLevelContext()) {
71458                 return ts.visitEachChild(node, visitor, context);
71459             }
71460             return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node);
71461         }
71462         function visitMethodDeclaration(node) {
71463             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
71464                 ? transformAsyncFunctionBody(node)
71465                 : ts.visitFunctionBody(node.body, visitor, context));
71466         }
71467         function visitFunctionDeclaration(node) {
71468             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
71469                 ? transformAsyncFunctionBody(node)
71470                 : ts.visitFunctionBody(node.body, visitor, context));
71471         }
71472         function visitFunctionExpression(node) {
71473             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
71474                 ? transformAsyncFunctionBody(node)
71475                 : ts.visitFunctionBody(node.body, visitor, context));
71476         }
71477         function visitArrowFunction(node) {
71478             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
71479                 ? transformAsyncFunctionBody(node)
71480                 : ts.visitFunctionBody(node.body, visitor, context));
71481         }
71482         function recordDeclarationName(_a, names) {
71483             var name = _a.name;
71484             if (ts.isIdentifier(name)) {
71485                 names.add(name.escapedText);
71486             }
71487             else {
71488                 for (var _i = 0, _b = name.elements; _i < _b.length; _i++) {
71489                     var element = _b[_i];
71490                     if (!ts.isOmittedExpression(element)) {
71491                         recordDeclarationName(element, names);
71492                     }
71493                 }
71494             }
71495         }
71496         function isVariableDeclarationListWithCollidingName(node) {
71497             return !!node
71498                 && ts.isVariableDeclarationList(node)
71499                 && !(node.flags & 3)
71500                 && node.declarations.some(collidesWithParameterName);
71501         }
71502         function visitVariableDeclarationListWithCollidingNames(node, hasReceiver) {
71503             hoistVariableDeclarationList(node);
71504             var variables = ts.getInitializedVariables(node);
71505             if (variables.length === 0) {
71506                 if (hasReceiver) {
71507                     return ts.visitNode(factory.converters.convertToAssignmentElementTarget(node.declarations[0].name), visitor, ts.isExpression);
71508                 }
71509                 return undefined;
71510             }
71511             return factory.inlineExpressions(ts.map(variables, transformInitializedVariable));
71512         }
71513         function hoistVariableDeclarationList(node) {
71514             ts.forEach(node.declarations, hoistVariable);
71515         }
71516         function hoistVariable(_a) {
71517             var name = _a.name;
71518             if (ts.isIdentifier(name)) {
71519                 hoistVariableDeclaration(name);
71520             }
71521             else {
71522                 for (var _i = 0, _b = name.elements; _i < _b.length; _i++) {
71523                     var element = _b[_i];
71524                     if (!ts.isOmittedExpression(element)) {
71525                         hoistVariable(element);
71526                     }
71527                 }
71528             }
71529         }
71530         function transformInitializedVariable(node) {
71531             var converted = ts.setSourceMapRange(factory.createAssignment(factory.converters.convertToAssignmentElementTarget(node.name), node.initializer), node);
71532             return ts.visitNode(converted, visitor, ts.isExpression);
71533         }
71534         function collidesWithParameterName(_a) {
71535             var name = _a.name;
71536             if (ts.isIdentifier(name)) {
71537                 return enclosingFunctionParameterNames.has(name.escapedText);
71538             }
71539             else {
71540                 for (var _i = 0, _b = name.elements; _i < _b.length; _i++) {
71541                     var element = _b[_i];
71542                     if (!ts.isOmittedExpression(element) && collidesWithParameterName(element)) {
71543                         return true;
71544                     }
71545                 }
71546             }
71547             return false;
71548         }
71549         function transformAsyncFunctionBody(node) {
71550             resumeLexicalEnvironment();
71551             var original = ts.getOriginalNode(node, ts.isFunctionLike);
71552             var nodeType = original.type;
71553             var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined;
71554             var isArrowFunction = node.kind === 209;
71555             var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0;
71556             var savedEnclosingFunctionParameterNames = enclosingFunctionParameterNames;
71557             enclosingFunctionParameterNames = new ts.Set();
71558             for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
71559                 var parameter = _a[_i];
71560                 recordDeclarationName(parameter, enclosingFunctionParameterNames);
71561             }
71562             var savedCapturedSuperProperties = capturedSuperProperties;
71563             var savedHasSuperElementAccess = hasSuperElementAccess;
71564             if (!isArrowFunction) {
71565                 capturedSuperProperties = new ts.Set();
71566                 hasSuperElementAccess = false;
71567             }
71568             var result;
71569             if (!isArrowFunction) {
71570                 var statements = [];
71571                 var statementOffset = factory.copyPrologue(node.body.statements, statements, false, visitor);
71572                 statements.push(factory.createReturnStatement(emitHelpers().createAwaiterHelper(inHasLexicalThisContext(), hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset))));
71573                 ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
71574                 var emitSuperHelpers = languageVersion >= 2 && resolver.getNodeCheckFlags(node) & (4096 | 2048);
71575                 if (emitSuperHelpers) {
71576                     enableSubstitutionForAsyncMethodsWithSuper();
71577                     if (capturedSuperProperties.size) {
71578                         var variableStatement = createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties);
71579                         substitutedSuperAccessors[ts.getNodeId(variableStatement)] = true;
71580                         ts.insertStatementsAfterStandardPrologue(statements, [variableStatement]);
71581                     }
71582                 }
71583                 var block = factory.createBlock(statements, true);
71584                 ts.setTextRange(block, node.body);
71585                 if (emitSuperHelpers && hasSuperElementAccess) {
71586                     if (resolver.getNodeCheckFlags(node) & 4096) {
71587                         ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
71588                     }
71589                     else if (resolver.getNodeCheckFlags(node) & 2048) {
71590                         ts.addEmitHelper(block, ts.asyncSuperHelper);
71591                     }
71592                 }
71593                 result = block;
71594             }
71595             else {
71596                 var expression = emitHelpers().createAwaiterHelper(inHasLexicalThisContext(), hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body));
71597                 var declarations = endLexicalEnvironment();
71598                 if (ts.some(declarations)) {
71599                     var block = factory.converters.convertToFunctionBlock(expression);
71600                     result = factory.updateBlock(block, ts.setTextRange(factory.createNodeArray(ts.concatenate(declarations, block.statements)), block.statements));
71601                 }
71602                 else {
71603                     result = expression;
71604                 }
71605             }
71606             enclosingFunctionParameterNames = savedEnclosingFunctionParameterNames;
71607             if (!isArrowFunction) {
71608                 capturedSuperProperties = savedCapturedSuperProperties;
71609                 hasSuperElementAccess = savedHasSuperElementAccess;
71610             }
71611             return result;
71612         }
71613         function transformAsyncFunctionBodyWorker(body, start) {
71614             if (ts.isBlock(body)) {
71615                 return factory.updateBlock(body, ts.visitNodes(body.statements, asyncBodyVisitor, ts.isStatement, start));
71616             }
71617             else {
71618                 return factory.converters.convertToFunctionBlock(ts.visitNode(body, asyncBodyVisitor, ts.isConciseBody));
71619             }
71620         }
71621         function getPromiseConstructor(type) {
71622             var typeName = type && ts.getEntityNameFromTypeNode(type);
71623             if (typeName && ts.isEntityName(typeName)) {
71624                 var serializationKind = resolver.getTypeReferenceSerializationKind(typeName);
71625                 if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue
71626                     || serializationKind === ts.TypeReferenceSerializationKind.Unknown) {
71627                     return typeName;
71628                 }
71629             }
71630             return undefined;
71631         }
71632         function enableSubstitutionForAsyncMethodsWithSuper() {
71633             if ((enabledSubstitutions & 1) === 0) {
71634                 enabledSubstitutions |= 1;
71635                 context.enableSubstitution(203);
71636                 context.enableSubstitution(201);
71637                 context.enableSubstitution(202);
71638                 context.enableEmitNotification(252);
71639                 context.enableEmitNotification(165);
71640                 context.enableEmitNotification(167);
71641                 context.enableEmitNotification(168);
71642                 context.enableEmitNotification(166);
71643                 context.enableEmitNotification(232);
71644             }
71645         }
71646         function onEmitNode(hint, node, emitCallback) {
71647             if (enabledSubstitutions & 1 && isSuperContainer(node)) {
71648                 var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 | 4096);
71649                 if (superContainerFlags !== enclosingSuperContainerFlags) {
71650                     var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
71651                     enclosingSuperContainerFlags = superContainerFlags;
71652                     previousOnEmitNode(hint, node, emitCallback);
71653                     enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
71654                     return;
71655                 }
71656             }
71657             else if (enabledSubstitutions && substitutedSuperAccessors[ts.getNodeId(node)]) {
71658                 var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
71659                 enclosingSuperContainerFlags = 0;
71660                 previousOnEmitNode(hint, node, emitCallback);
71661                 enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
71662                 return;
71663             }
71664             previousOnEmitNode(hint, node, emitCallback);
71665         }
71666         function onSubstituteNode(hint, node) {
71667             node = previousOnSubstituteNode(hint, node);
71668             if (hint === 1 && enclosingSuperContainerFlags) {
71669                 return substituteExpression(node);
71670             }
71671             return node;
71672         }
71673         function substituteExpression(node) {
71674             switch (node.kind) {
71675                 case 201:
71676                     return substitutePropertyAccessExpression(node);
71677                 case 202:
71678                     return substituteElementAccessExpression(node);
71679                 case 203:
71680                     return substituteCallExpression(node);
71681             }
71682             return node;
71683         }
71684         function substitutePropertyAccessExpression(node) {
71685             if (node.expression.kind === 105) {
71686                 return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 | 32), node.name), node);
71687             }
71688             return node;
71689         }
71690         function substituteElementAccessExpression(node) {
71691             if (node.expression.kind === 105) {
71692                 return createSuperElementAccessInAsyncMethod(node.argumentExpression, node);
71693             }
71694             return node;
71695         }
71696         function substituteCallExpression(node) {
71697             var expression = node.expression;
71698             if (ts.isSuperProperty(expression)) {
71699                 var argumentExpression = ts.isPropertyAccessExpression(expression)
71700                     ? substitutePropertyAccessExpression(expression)
71701                     : substituteElementAccessExpression(expression);
71702                 return factory.createCallExpression(factory.createPropertyAccessExpression(argumentExpression, "call"), undefined, __spreadArrays([
71703                     factory.createThis()
71704                 ], node.arguments));
71705             }
71706             return node;
71707         }
71708         function isSuperContainer(node) {
71709             var kind = node.kind;
71710             return kind === 252
71711                 || kind === 166
71712                 || kind === 165
71713                 || kind === 167
71714                 || kind === 168;
71715         }
71716         function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
71717             if (enclosingSuperContainerFlags & 4096) {
71718                 return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 | 32), undefined, [argumentExpression]), "value"), location);
71719             }
71720             else {
71721                 return ts.setTextRange(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 | 32), undefined, [argumentExpression]), location);
71722             }
71723         }
71724     }
71725     ts.transformES2017 = transformES2017;
71726     function createSuperAccessVariableStatement(factory, resolver, node, names) {
71727         var hasBinding = (resolver.getNodeCheckFlags(node) & 4096) !== 0;
71728         var accessors = [];
71729         names.forEach(function (_, key) {
71730             var name = ts.unescapeLeadingUnderscores(key);
71731             var getterAndSetter = [];
71732             getterAndSetter.push(factory.createPropertyAssignment("get", factory.createArrowFunction(undefined, undefined, [], undefined, undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4), name), 4))));
71733             if (hasBinding) {
71734                 getterAndSetter.push(factory.createPropertyAssignment("set", factory.createArrowFunction(undefined, undefined, [
71735                     factory.createParameterDeclaration(undefined, undefined, undefined, "v", undefined, undefined, undefined)
71736                 ], undefined, undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4), name), 4), factory.createIdentifier("v")))));
71737             }
71738             accessors.push(factory.createPropertyAssignment(name, factory.createObjectLiteralExpression(getterAndSetter)));
71739         });
71740         return factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
71741             factory.createVariableDeclaration(factory.createUniqueName("_super", 16 | 32), undefined, undefined, factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "create"), undefined, [
71742                 factory.createNull(),
71743                 factory.createObjectLiteralExpression(accessors, true)
71744             ]))
71745         ], 2));
71746     }
71747     ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement;
71748 })(ts || (ts = {}));
71749 var ts;
71750 (function (ts) {
71751     function transformES2018(context) {
71752         var factory = context.factory, emitHelpers = context.getEmitHelperFactory, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
71753         var resolver = context.getEmitResolver();
71754         var compilerOptions = context.getCompilerOptions();
71755         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
71756         var previousOnEmitNode = context.onEmitNode;
71757         context.onEmitNode = onEmitNode;
71758         var previousOnSubstituteNode = context.onSubstituteNode;
71759         context.onSubstituteNode = onSubstituteNode;
71760         var exportedVariableStatement = false;
71761         var enabledSubstitutions;
71762         var enclosingFunctionFlags;
71763         var enclosingSuperContainerFlags = 0;
71764         var hierarchyFacts = 0;
71765         var currentSourceFile;
71766         var taggedTemplateStringDeclarations;
71767         var capturedSuperProperties;
71768         var hasSuperElementAccess;
71769         var substitutedSuperAccessors = [];
71770         return ts.chainBundle(context, transformSourceFile);
71771         function affectsSubtree(excludeFacts, includeFacts) {
71772             return hierarchyFacts !== (hierarchyFacts & ~excludeFacts | includeFacts);
71773         }
71774         function enterSubtree(excludeFacts, includeFacts) {
71775             var ancestorFacts = hierarchyFacts;
71776             hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3;
71777             return ancestorFacts;
71778         }
71779         function exitSubtree(ancestorFacts) {
71780             hierarchyFacts = ancestorFacts;
71781         }
71782         function recordTaggedTemplateString(temp) {
71783             taggedTemplateStringDeclarations = ts.append(taggedTemplateStringDeclarations, factory.createVariableDeclaration(temp));
71784         }
71785         function transformSourceFile(node) {
71786             if (node.isDeclarationFile) {
71787                 return node;
71788             }
71789             currentSourceFile = node;
71790             var visited = visitSourceFile(node);
71791             ts.addEmitHelpers(visited, context.readEmitHelpers());
71792             currentSourceFile = undefined;
71793             taggedTemplateStringDeclarations = undefined;
71794             return visited;
71795         }
71796         function visitor(node) {
71797             return visitorWorker(node, false);
71798         }
71799         function visitorWithUnusedExpressionResult(node) {
71800             return visitorWorker(node, true);
71801         }
71802         function visitorNoAsyncModifier(node) {
71803             if (node.kind === 129) {
71804                 return undefined;
71805             }
71806             return node;
71807         }
71808         function doWithHierarchyFacts(cb, value, excludeFacts, includeFacts) {
71809             if (affectsSubtree(excludeFacts, includeFacts)) {
71810                 var ancestorFacts = enterSubtree(excludeFacts, includeFacts);
71811                 var result = cb(value);
71812                 exitSubtree(ancestorFacts);
71813                 return result;
71814             }
71815             return cb(value);
71816         }
71817         function visitDefault(node) {
71818             return ts.visitEachChild(node, visitor, context);
71819         }
71820         function visitorWorker(node, expressionResultIsUnused) {
71821             if ((node.transformFlags & 32) === 0) {
71822                 return node;
71823             }
71824             switch (node.kind) {
71825                 case 213:
71826                     return visitAwaitExpression(node);
71827                 case 219:
71828                     return visitYieldExpression(node);
71829                 case 242:
71830                     return visitReturnStatement(node);
71831                 case 245:
71832                     return visitLabeledStatement(node);
71833                 case 200:
71834                     return visitObjectLiteralExpression(node);
71835                 case 216:
71836                     return visitBinaryExpression(node, expressionResultIsUnused);
71837                 case 337:
71838                     return visitCommaListExpression(node, expressionResultIsUnused);
71839                 case 287:
71840                     return visitCatchClause(node);
71841                 case 232:
71842                     return visitVariableStatement(node);
71843                 case 249:
71844                     return visitVariableDeclaration(node);
71845                 case 235:
71846                 case 236:
71847                 case 238:
71848                     return doWithHierarchyFacts(visitDefault, node, 0, 2);
71849                 case 239:
71850                     return visitForOfStatement(node, undefined);
71851                 case 237:
71852                     return doWithHierarchyFacts(visitForStatement, node, 0, 2);
71853                 case 212:
71854                     return visitVoidExpression(node);
71855                 case 166:
71856                     return doWithHierarchyFacts(visitConstructorDeclaration, node, 2, 1);
71857                 case 165:
71858                     return doWithHierarchyFacts(visitMethodDeclaration, node, 2, 1);
71859                 case 167:
71860                     return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2, 1);
71861                 case 168:
71862                     return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2, 1);
71863                 case 251:
71864                     return doWithHierarchyFacts(visitFunctionDeclaration, node, 2, 1);
71865                 case 208:
71866                     return doWithHierarchyFacts(visitFunctionExpression, node, 2, 1);
71867                 case 209:
71868                     return doWithHierarchyFacts(visitArrowFunction, node, 2, 0);
71869                 case 160:
71870                     return visitParameter(node);
71871                 case 233:
71872                     return visitExpressionStatement(node);
71873                 case 207:
71874                     return visitParenthesizedExpression(node, expressionResultIsUnused);
71875                 case 205:
71876                     return visitTaggedTemplateExpression(node);
71877                 case 201:
71878                     if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 105) {
71879                         capturedSuperProperties.add(node.name.escapedText);
71880                     }
71881                     return ts.visitEachChild(node, visitor, context);
71882                 case 202:
71883                     if (capturedSuperProperties && node.expression.kind === 105) {
71884                         hasSuperElementAccess = true;
71885                     }
71886                     return ts.visitEachChild(node, visitor, context);
71887                 case 252:
71888                 case 221:
71889                     return doWithHierarchyFacts(visitDefault, node, 2, 1);
71890                 default:
71891                     return ts.visitEachChild(node, visitor, context);
71892             }
71893         }
71894         function visitAwaitExpression(node) {
71895             if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) {
71896                 return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(undefined, emitHelpers().createAwaitHelper(ts.visitNode(node.expression, visitor, ts.isExpression))), node), node);
71897             }
71898             return ts.visitEachChild(node, visitor, context);
71899         }
71900         function visitYieldExpression(node) {
71901             if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) {
71902                 if (node.asteriskToken) {
71903                     var expression = ts.visitNode(ts.Debug.assertDefined(node.expression), visitor, ts.isExpression);
71904                     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);
71905                 }
71906                 return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(undefined, createDownlevelAwait(node.expression
71907                     ? ts.visitNode(node.expression, visitor, ts.isExpression)
71908                     : factory.createVoidZero())), node), node);
71909             }
71910             return ts.visitEachChild(node, visitor, context);
71911         }
71912         function visitReturnStatement(node) {
71913             if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) {
71914                 return factory.updateReturnStatement(node, createDownlevelAwait(node.expression ? ts.visitNode(node.expression, visitor, ts.isExpression) : factory.createVoidZero()));
71915             }
71916             return ts.visitEachChild(node, visitor, context);
71917         }
71918         function visitLabeledStatement(node) {
71919             if (enclosingFunctionFlags & 2) {
71920                 var statement = ts.unwrapInnermostStatementOfLabel(node);
71921                 if (statement.kind === 239 && statement.awaitModifier) {
71922                     return visitForOfStatement(statement, node);
71923                 }
71924                 return factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node);
71925             }
71926             return ts.visitEachChild(node, visitor, context);
71927         }
71928         function chunkObjectLiteralElements(elements) {
71929             var chunkObject;
71930             var objects = [];
71931             for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) {
71932                 var e = elements_4[_i];
71933                 if (e.kind === 290) {
71934                     if (chunkObject) {
71935                         objects.push(factory.createObjectLiteralExpression(chunkObject));
71936                         chunkObject = undefined;
71937                     }
71938                     var target = e.expression;
71939                     objects.push(ts.visitNode(target, visitor, ts.isExpression));
71940                 }
71941                 else {
71942                     chunkObject = ts.append(chunkObject, e.kind === 288
71943                         ? factory.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression))
71944                         : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike));
71945                 }
71946             }
71947             if (chunkObject) {
71948                 objects.push(factory.createObjectLiteralExpression(chunkObject));
71949             }
71950             return objects;
71951         }
71952         function visitObjectLiteralExpression(node) {
71953             if (node.transformFlags & 16384) {
71954                 var objects = chunkObjectLiteralElements(node.properties);
71955                 if (objects.length && objects[0].kind !== 200) {
71956                     objects.unshift(factory.createObjectLiteralExpression());
71957                 }
71958                 var expression = objects[0];
71959                 if (objects.length > 1) {
71960                     for (var i = 1; i < objects.length; i++) {
71961                         expression = emitHelpers().createAssignHelper([expression, objects[i]]);
71962                     }
71963                     return expression;
71964                 }
71965                 else {
71966                     return emitHelpers().createAssignHelper(objects);
71967                 }
71968             }
71969             return ts.visitEachChild(node, visitor, context);
71970         }
71971         function visitExpressionStatement(node) {
71972             return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
71973         }
71974         function visitParenthesizedExpression(node, expressionResultIsUnused) {
71975             return ts.visitEachChild(node, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, context);
71976         }
71977         function visitSourceFile(node) {
71978             var ancestorFacts = enterSubtree(2, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ?
71979                 0 :
71980                 1);
71981             exportedVariableStatement = false;
71982             var visited = ts.visitEachChild(node, visitor, context);
71983             var statement = ts.concatenate(visited.statements, taggedTemplateStringDeclarations && [
71984                 factory.createVariableStatement(undefined, factory.createVariableDeclarationList(taggedTemplateStringDeclarations))
71985             ]);
71986             var result = factory.updateSourceFile(visited, ts.setTextRange(factory.createNodeArray(statement), node.statements));
71987             exitSubtree(ancestorFacts);
71988             return result;
71989         }
71990         function visitTaggedTemplateExpression(node) {
71991             return ts.processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, ts.ProcessLevel.LiftRestriction);
71992         }
71993         function visitBinaryExpression(node, expressionResultIsUnused) {
71994             if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 16384) {
71995                 return ts.flattenDestructuringAssignment(node, visitor, context, 1, !expressionResultIsUnused);
71996             }
71997             if (node.operatorToken.kind === 27) {
71998                 return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression));
71999             }
72000             return ts.visitEachChild(node, visitor, context);
72001         }
72002         function visitCommaListExpression(node, expressionResultIsUnused) {
72003             if (expressionResultIsUnused) {
72004                 return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
72005             }
72006             var result;
72007             for (var i = 0; i < node.elements.length; i++) {
72008                 var element = node.elements[i];
72009                 var visited = ts.visitNode(element, i < node.elements.length - 1 ? visitorWithUnusedExpressionResult : visitor, ts.isExpression);
72010                 if (result || visited !== element) {
72011                     result || (result = node.elements.slice(0, i));
72012                     result.push(visited);
72013                 }
72014             }
72015             var elements = result ? ts.setTextRange(factory.createNodeArray(result), node.elements) : node.elements;
72016             return factory.updateCommaListExpression(node, elements);
72017         }
72018         function visitCatchClause(node) {
72019             if (node.variableDeclaration &&
72020                 ts.isBindingPattern(node.variableDeclaration.name) &&
72021                 node.variableDeclaration.name.transformFlags & 16384) {
72022                 var name = factory.getGeneratedNameForNode(node.variableDeclaration.name);
72023                 var updatedDecl = factory.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, undefined, undefined, name);
72024                 var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1);
72025                 var block = ts.visitNode(node.block, visitor, ts.isBlock);
72026                 if (ts.some(visitedBindings)) {
72027                     block = factory.updateBlock(block, __spreadArrays([
72028                         factory.createVariableStatement(undefined, visitedBindings)
72029                     ], block.statements));
72030                 }
72031                 return factory.updateCatchClause(node, factory.updateVariableDeclaration(node.variableDeclaration, name, undefined, undefined, undefined), block);
72032             }
72033             return ts.visitEachChild(node, visitor, context);
72034         }
72035         function visitVariableStatement(node) {
72036             if (ts.hasSyntacticModifier(node, 1)) {
72037                 var savedExportedVariableStatement = exportedVariableStatement;
72038                 exportedVariableStatement = true;
72039                 var visited = ts.visitEachChild(node, visitor, context);
72040                 exportedVariableStatement = savedExportedVariableStatement;
72041                 return visited;
72042             }
72043             return ts.visitEachChild(node, visitor, context);
72044         }
72045         function visitVariableDeclaration(node) {
72046             if (exportedVariableStatement) {
72047                 var savedExportedVariableStatement = exportedVariableStatement;
72048                 exportedVariableStatement = false;
72049                 var visited = visitVariableDeclarationWorker(node, true);
72050                 exportedVariableStatement = savedExportedVariableStatement;
72051                 return visited;
72052             }
72053             return visitVariableDeclarationWorker(node, false);
72054         }
72055         function visitVariableDeclarationWorker(node, exportedVariableStatement) {
72056             if (ts.isBindingPattern(node.name) && node.name.transformFlags & 16384) {
72057                 return ts.flattenDestructuringBinding(node, visitor, context, 1, undefined, exportedVariableStatement);
72058             }
72059             return ts.visitEachChild(node, visitor, context);
72060         }
72061         function visitForStatement(node) {
72062             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));
72063         }
72064         function visitVoidExpression(node) {
72065             return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
72066         }
72067         function visitForOfStatement(node, outermostLabeledStatement) {
72068             var ancestorFacts = enterSubtree(0, 2);
72069             if (node.initializer.transformFlags & 16384) {
72070                 node = transformForOfStatementWithObjectRest(node);
72071             }
72072             var result = node.awaitModifier ?
72073                 transformForAwaitOfStatement(node, outermostLabeledStatement, ancestorFacts) :
72074                 factory.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement);
72075             exitSubtree(ancestorFacts);
72076             return result;
72077         }
72078         function transformForOfStatementWithObjectRest(node) {
72079             var initializerWithoutParens = ts.skipParentheses(node.initializer);
72080             if (ts.isVariableDeclarationList(initializerWithoutParens) || ts.isAssignmentPattern(initializerWithoutParens)) {
72081                 var bodyLocation = void 0;
72082                 var statementsLocation = void 0;
72083                 var temp = factory.createTempVariable(undefined);
72084                 var statements = [ts.createForOfBindingStatement(factory, initializerWithoutParens, temp)];
72085                 if (ts.isBlock(node.statement)) {
72086                     ts.addRange(statements, node.statement.statements);
72087                     bodyLocation = node.statement;
72088                     statementsLocation = node.statement.statements;
72089                 }
72090                 else if (node.statement) {
72091                     ts.append(statements, node.statement);
72092                     bodyLocation = node.statement;
72093                     statementsLocation = node.statement;
72094                 }
72095                 return factory.updateForOfStatement(node, node.awaitModifier, ts.setTextRange(factory.createVariableDeclarationList([
72096                     ts.setTextRange(factory.createVariableDeclaration(temp), node.initializer)
72097                 ], 1), node.initializer), node.expression, ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), true), bodyLocation));
72098             }
72099             return node;
72100         }
72101         function convertForOfStatementHead(node, boundValue) {
72102             var binding = ts.createForOfBindingStatement(factory, node.initializer, boundValue);
72103             var bodyLocation;
72104             var statementsLocation;
72105             var statements = [ts.visitNode(binding, visitor, ts.isStatement)];
72106             var statement = ts.visitNode(node.statement, visitor, ts.isStatement);
72107             if (ts.isBlock(statement)) {
72108                 ts.addRange(statements, statement.statements);
72109                 bodyLocation = statement;
72110                 statementsLocation = statement.statements;
72111             }
72112             else {
72113                 statements.push(statement);
72114             }
72115             return ts.setEmitFlags(ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), true), bodyLocation), 48 | 384);
72116         }
72117         function createDownlevelAwait(expression) {
72118             return enclosingFunctionFlags & 1
72119                 ? factory.createYieldExpression(undefined, emitHelpers().createAwaitHelper(expression))
72120                 : factory.createAwaitExpression(expression);
72121         }
72122         function transformForAwaitOfStatement(node, outermostLabeledStatement, ancestorFacts) {
72123             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
72124             var iterator = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(expression) : factory.createTempVariable(undefined);
72125             var result = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(iterator) : factory.createTempVariable(undefined);
72126             var errorRecord = factory.createUniqueName("e");
72127             var catchVariable = factory.getGeneratedNameForNode(errorRecord);
72128             var returnMethod = factory.createTempVariable(undefined);
72129             var callValues = ts.setTextRange(emitHelpers().createAsyncValuesHelper(expression), node.expression);
72130             var callNext = factory.createCallExpression(factory.createPropertyAccessExpression(iterator, "next"), undefined, []);
72131             var getDone = factory.createPropertyAccessExpression(result, "done");
72132             var getValue = factory.createPropertyAccessExpression(result, "value");
72133             var callReturn = factory.createFunctionCallCall(returnMethod, iterator, []);
72134             hoistVariableDeclaration(errorRecord);
72135             hoistVariableDeclaration(returnMethod);
72136             var initializer = ancestorFacts & 2 ?
72137                 factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), callValues]) :
72138                 callValues;
72139             var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement(ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([
72140                 ts.setTextRange(factory.createVariableDeclaration(iterator, undefined, undefined, initializer), node.expression),
72141                 factory.createVariableDeclaration(result)
72142             ]), node.expression), 2097152), factory.createComma(factory.createAssignment(result, createDownlevelAwait(callNext)), factory.createLogicalNot(getDone)), undefined, convertForOfStatementHead(node, getValue)), node), 256);
72143             return factory.createTryStatement(factory.createBlock([
72144                 factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement)
72145             ]), factory.createCatchClause(factory.createVariableDeclaration(catchVariable), ts.setEmitFlags(factory.createBlock([
72146                 factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([
72147                     factory.createPropertyAssignment("error", catchVariable)
72148                 ])))
72149             ]), 1)), factory.createBlock([
72150                 factory.createTryStatement(factory.createBlock([
72151                     ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1)
72152                 ]), undefined, ts.setEmitFlags(factory.createBlock([
72153                     ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1)
72154                 ]), 1))
72155             ]));
72156         }
72157         function visitParameter(node) {
72158             if (node.transformFlags & 16384) {
72159                 return factory.updateParameterDeclaration(node, undefined, undefined, node.dotDotDotToken, factory.getGeneratedNameForNode(node), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
72160             }
72161             return ts.visitEachChild(node, visitor, context);
72162         }
72163         function visitConstructorDeclaration(node) {
72164             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
72165             enclosingFunctionFlags = 0;
72166             var updated = factory.updateConstructorDeclaration(node, undefined, node.modifiers, ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node));
72167             enclosingFunctionFlags = savedEnclosingFunctionFlags;
72168             return updated;
72169         }
72170         function visitGetAccessorDeclaration(node) {
72171             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
72172             enclosingFunctionFlags = 0;
72173             var updated = factory.updateGetAccessorDeclaration(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node));
72174             enclosingFunctionFlags = savedEnclosingFunctionFlags;
72175             return updated;
72176         }
72177         function visitSetAccessorDeclaration(node) {
72178             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
72179             enclosingFunctionFlags = 0;
72180             var updated = factory.updateSetAccessorDeclaration(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node));
72181             enclosingFunctionFlags = savedEnclosingFunctionFlags;
72182             return updated;
72183         }
72184         function visitMethodDeclaration(node) {
72185             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
72186             enclosingFunctionFlags = ts.getFunctionFlags(node);
72187             var updated = factory.updateMethodDeclaration(node, undefined, enclosingFunctionFlags & 1
72188                 ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
72189                 : node.modifiers, enclosingFunctionFlags & 2
72190                 ? undefined
72191                 : 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
72192                 ? transformAsyncGeneratorFunctionBody(node)
72193                 : transformFunctionBody(node));
72194             enclosingFunctionFlags = savedEnclosingFunctionFlags;
72195             return updated;
72196         }
72197         function visitFunctionDeclaration(node) {
72198             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
72199             enclosingFunctionFlags = ts.getFunctionFlags(node);
72200             var updated = factory.updateFunctionDeclaration(node, undefined, enclosingFunctionFlags & 1
72201                 ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
72202                 : node.modifiers, enclosingFunctionFlags & 2
72203                 ? undefined
72204                 : node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1
72205                 ? transformAsyncGeneratorFunctionBody(node)
72206                 : transformFunctionBody(node));
72207             enclosingFunctionFlags = savedEnclosingFunctionFlags;
72208             return updated;
72209         }
72210         function visitArrowFunction(node) {
72211             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
72212             enclosingFunctionFlags = ts.getFunctionFlags(node);
72213             var updated = factory.updateArrowFunction(node, node.modifiers, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.equalsGreaterThanToken, transformFunctionBody(node));
72214             enclosingFunctionFlags = savedEnclosingFunctionFlags;
72215             return updated;
72216         }
72217         function visitFunctionExpression(node) {
72218             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
72219             enclosingFunctionFlags = ts.getFunctionFlags(node);
72220             var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1
72221                 ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
72222                 : node.modifiers, enclosingFunctionFlags & 2
72223                 ? undefined
72224                 : node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1
72225                 ? transformAsyncGeneratorFunctionBody(node)
72226                 : transformFunctionBody(node));
72227             enclosingFunctionFlags = savedEnclosingFunctionFlags;
72228             return updated;
72229         }
72230         function transformAsyncGeneratorFunctionBody(node) {
72231             resumeLexicalEnvironment();
72232             var statements = [];
72233             var statementOffset = factory.copyPrologue(node.body.statements, statements, false, visitor);
72234             appendObjectRestAssignmentsIfNeeded(statements, node);
72235             var savedCapturedSuperProperties = capturedSuperProperties;
72236             var savedHasSuperElementAccess = hasSuperElementAccess;
72237             capturedSuperProperties = new ts.Set();
72238             hasSuperElementAccess = false;
72239             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)));
72240             var emitSuperHelpers = languageVersion >= 2 && resolver.getNodeCheckFlags(node) & (4096 | 2048);
72241             if (emitSuperHelpers) {
72242                 enableSubstitutionForAsyncMethodsWithSuper();
72243                 var variableStatement = ts.createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties);
72244                 substitutedSuperAccessors[ts.getNodeId(variableStatement)] = true;
72245                 ts.insertStatementsAfterStandardPrologue(statements, [variableStatement]);
72246             }
72247             statements.push(returnStatement);
72248             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
72249             var block = factory.updateBlock(node.body, statements);
72250             if (emitSuperHelpers && hasSuperElementAccess) {
72251                 if (resolver.getNodeCheckFlags(node) & 4096) {
72252                     ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
72253                 }
72254                 else if (resolver.getNodeCheckFlags(node) & 2048) {
72255                     ts.addEmitHelper(block, ts.asyncSuperHelper);
72256                 }
72257             }
72258             capturedSuperProperties = savedCapturedSuperProperties;
72259             hasSuperElementAccess = savedHasSuperElementAccess;
72260             return block;
72261         }
72262         function transformFunctionBody(node) {
72263             var _a;
72264             resumeLexicalEnvironment();
72265             var statementOffset = 0;
72266             var statements = [];
72267             var body = (_a = ts.visitNode(node.body, visitor, ts.isConciseBody)) !== null && _a !== void 0 ? _a : factory.createBlock([]);
72268             if (ts.isBlock(body)) {
72269                 statementOffset = factory.copyPrologue(body.statements, statements, false, visitor);
72270             }
72271             ts.addRange(statements, appendObjectRestAssignmentsIfNeeded(undefined, node));
72272             var leadingStatements = endLexicalEnvironment();
72273             if (statementOffset > 0 || ts.some(statements) || ts.some(leadingStatements)) {
72274                 var block = factory.converters.convertToFunctionBlock(body, true);
72275                 ts.insertStatementsAfterStandardPrologue(statements, leadingStatements);
72276                 ts.addRange(statements, block.statements.slice(statementOffset));
72277                 return factory.updateBlock(block, ts.setTextRange(factory.createNodeArray(statements), block.statements));
72278             }
72279             return body;
72280         }
72281         function appendObjectRestAssignmentsIfNeeded(statements, node) {
72282             for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
72283                 var parameter = _a[_i];
72284                 if (parameter.transformFlags & 16384) {
72285                     var temp = factory.getGeneratedNameForNode(parameter);
72286                     var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1, temp, false, true);
72287                     if (ts.some(declarations)) {
72288                         var statement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList(declarations));
72289                         ts.setEmitFlags(statement, 1048576);
72290                         statements = ts.append(statements, statement);
72291                     }
72292                 }
72293             }
72294             return statements;
72295         }
72296         function enableSubstitutionForAsyncMethodsWithSuper() {
72297             if ((enabledSubstitutions & 1) === 0) {
72298                 enabledSubstitutions |= 1;
72299                 context.enableSubstitution(203);
72300                 context.enableSubstitution(201);
72301                 context.enableSubstitution(202);
72302                 context.enableEmitNotification(252);
72303                 context.enableEmitNotification(165);
72304                 context.enableEmitNotification(167);
72305                 context.enableEmitNotification(168);
72306                 context.enableEmitNotification(166);
72307                 context.enableEmitNotification(232);
72308             }
72309         }
72310         function onEmitNode(hint, node, emitCallback) {
72311             if (enabledSubstitutions & 1 && isSuperContainer(node)) {
72312                 var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 | 4096);
72313                 if (superContainerFlags !== enclosingSuperContainerFlags) {
72314                     var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
72315                     enclosingSuperContainerFlags = superContainerFlags;
72316                     previousOnEmitNode(hint, node, emitCallback);
72317                     enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
72318                     return;
72319                 }
72320             }
72321             else if (enabledSubstitutions && substitutedSuperAccessors[ts.getNodeId(node)]) {
72322                 var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
72323                 enclosingSuperContainerFlags = 0;
72324                 previousOnEmitNode(hint, node, emitCallback);
72325                 enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
72326                 return;
72327             }
72328             previousOnEmitNode(hint, node, emitCallback);
72329         }
72330         function onSubstituteNode(hint, node) {
72331             node = previousOnSubstituteNode(hint, node);
72332             if (hint === 1 && enclosingSuperContainerFlags) {
72333                 return substituteExpression(node);
72334             }
72335             return node;
72336         }
72337         function substituteExpression(node) {
72338             switch (node.kind) {
72339                 case 201:
72340                     return substitutePropertyAccessExpression(node);
72341                 case 202:
72342                     return substituteElementAccessExpression(node);
72343                 case 203:
72344                     return substituteCallExpression(node);
72345             }
72346             return node;
72347         }
72348         function substitutePropertyAccessExpression(node) {
72349             if (node.expression.kind === 105) {
72350                 return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 | 32), node.name), node);
72351             }
72352             return node;
72353         }
72354         function substituteElementAccessExpression(node) {
72355             if (node.expression.kind === 105) {
72356                 return createSuperElementAccessInAsyncMethod(node.argumentExpression, node);
72357             }
72358             return node;
72359         }
72360         function substituteCallExpression(node) {
72361             var expression = node.expression;
72362             if (ts.isSuperProperty(expression)) {
72363                 var argumentExpression = ts.isPropertyAccessExpression(expression)
72364                     ? substitutePropertyAccessExpression(expression)
72365                     : substituteElementAccessExpression(expression);
72366                 return factory.createCallExpression(factory.createPropertyAccessExpression(argumentExpression, "call"), undefined, __spreadArrays([
72367                     factory.createThis()
72368                 ], node.arguments));
72369             }
72370             return node;
72371         }
72372         function isSuperContainer(node) {
72373             var kind = node.kind;
72374             return kind === 252
72375                 || kind === 166
72376                 || kind === 165
72377                 || kind === 167
72378                 || kind === 168;
72379         }
72380         function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
72381             if (enclosingSuperContainerFlags & 4096) {
72382                 return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createIdentifier("_superIndex"), undefined, [argumentExpression]), "value"), location);
72383             }
72384             else {
72385                 return ts.setTextRange(factory.createCallExpression(factory.createIdentifier("_superIndex"), undefined, [argumentExpression]), location);
72386             }
72387         }
72388     }
72389     ts.transformES2018 = transformES2018;
72390 })(ts || (ts = {}));
72391 var ts;
72392 (function (ts) {
72393     function transformES2019(context) {
72394         var factory = context.factory;
72395         return ts.chainBundle(context, transformSourceFile);
72396         function transformSourceFile(node) {
72397             if (node.isDeclarationFile) {
72398                 return node;
72399             }
72400             return ts.visitEachChild(node, visitor, context);
72401         }
72402         function visitor(node) {
72403             if ((node.transformFlags & 16) === 0) {
72404                 return node;
72405             }
72406             switch (node.kind) {
72407                 case 287:
72408                     return visitCatchClause(node);
72409                 default:
72410                     return ts.visitEachChild(node, visitor, context);
72411             }
72412         }
72413         function visitCatchClause(node) {
72414             if (!node.variableDeclaration) {
72415                 return factory.updateCatchClause(node, factory.createVariableDeclaration(factory.createTempVariable(undefined)), ts.visitNode(node.block, visitor, ts.isBlock));
72416             }
72417             return ts.visitEachChild(node, visitor, context);
72418         }
72419     }
72420     ts.transformES2019 = transformES2019;
72421 })(ts || (ts = {}));
72422 var ts;
72423 (function (ts) {
72424     function transformES2020(context) {
72425         var factory = context.factory, hoistVariableDeclaration = context.hoistVariableDeclaration;
72426         return ts.chainBundle(context, transformSourceFile);
72427         function transformSourceFile(node) {
72428             if (node.isDeclarationFile) {
72429                 return node;
72430             }
72431             return ts.visitEachChild(node, visitor, context);
72432         }
72433         function visitor(node) {
72434             if ((node.transformFlags & 8) === 0) {
72435                 return node;
72436             }
72437             switch (node.kind) {
72438                 case 201:
72439                 case 202:
72440                 case 203:
72441                     if (node.flags & 32) {
72442                         var updated = visitOptionalExpression(node, false, false);
72443                         ts.Debug.assertNotNode(updated, ts.isSyntheticReference);
72444                         return updated;
72445                     }
72446                     return ts.visitEachChild(node, visitor, context);
72447                 case 216:
72448                     if (node.operatorToken.kind === 60) {
72449                         return transformNullishCoalescingExpression(node);
72450                     }
72451                     return ts.visitEachChild(node, visitor, context);
72452                 case 210:
72453                     return visitDeleteExpression(node);
72454                 default:
72455                     return ts.visitEachChild(node, visitor, context);
72456             }
72457         }
72458         function flattenChain(chain) {
72459             ts.Debug.assertNotNode(chain, ts.isNonNullChain);
72460             var links = [chain];
72461             while (!chain.questionDotToken && !ts.isTaggedTemplateExpression(chain)) {
72462                 chain = ts.cast(ts.skipPartiallyEmittedExpressions(chain.expression), ts.isOptionalChain);
72463                 ts.Debug.assertNotNode(chain, ts.isNonNullChain);
72464                 links.unshift(chain);
72465             }
72466             return { expression: chain.expression, chain: links };
72467         }
72468         function visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete) {
72469             var expression = visitNonOptionalExpression(node.expression, captureThisArg, isDelete);
72470             if (ts.isSyntheticReference(expression)) {
72471                 return factory.createSyntheticReferenceExpression(factory.updateParenthesizedExpression(node, expression.expression), expression.thisArg);
72472             }
72473             return factory.updateParenthesizedExpression(node, expression);
72474         }
72475         function visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete) {
72476             if (ts.isOptionalChain(node)) {
72477                 return visitOptionalExpression(node, captureThisArg, isDelete);
72478             }
72479             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
72480             ts.Debug.assertNotNode(expression, ts.isSyntheticReference);
72481             var thisArg;
72482             if (captureThisArg) {
72483                 if (!ts.isSimpleCopiableExpression(expression)) {
72484                     thisArg = factory.createTempVariable(hoistVariableDeclaration);
72485                     expression = factory.createAssignment(thisArg, expression);
72486                 }
72487                 else {
72488                     thisArg = expression;
72489                 }
72490             }
72491             expression = node.kind === 201
72492                 ? factory.updatePropertyAccessExpression(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier))
72493                 : factory.updateElementAccessExpression(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression));
72494             return thisArg ? factory.createSyntheticReferenceExpression(expression, thisArg) : expression;
72495         }
72496         function visitNonOptionalCallExpression(node, captureThisArg) {
72497             if (ts.isOptionalChain(node)) {
72498                 return visitOptionalExpression(node, captureThisArg, false);
72499             }
72500             return ts.visitEachChild(node, visitor, context);
72501         }
72502         function visitNonOptionalExpression(node, captureThisArg, isDelete) {
72503             switch (node.kind) {
72504                 case 207: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete);
72505                 case 201:
72506                 case 202: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete);
72507                 case 203: return visitNonOptionalCallExpression(node, captureThisArg);
72508                 default: return ts.visitNode(node, visitor, ts.isExpression);
72509             }
72510         }
72511         function visitOptionalExpression(node, captureThisArg, isDelete) {
72512             var _a = flattenChain(node), expression = _a.expression, chain = _a.chain;
72513             var left = visitNonOptionalExpression(expression, ts.isCallChain(chain[0]), false);
72514             var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined;
72515             var leftExpression = ts.isSyntheticReference(left) ? left.expression : left;
72516             var capturedLeft = leftExpression;
72517             if (!ts.isSimpleCopiableExpression(leftExpression)) {
72518                 capturedLeft = factory.createTempVariable(hoistVariableDeclaration);
72519                 leftExpression = factory.createAssignment(capturedLeft, leftExpression);
72520             }
72521             var rightExpression = capturedLeft;
72522             var thisArg;
72523             for (var i = 0; i < chain.length; i++) {
72524                 var segment = chain[i];
72525                 switch (segment.kind) {
72526                     case 201:
72527                     case 202:
72528                         if (i === chain.length - 1 && captureThisArg) {
72529                             if (!ts.isSimpleCopiableExpression(rightExpression)) {
72530                                 thisArg = factory.createTempVariable(hoistVariableDeclaration);
72531                                 rightExpression = factory.createAssignment(thisArg, rightExpression);
72532                             }
72533                             else {
72534                                 thisArg = rightExpression;
72535                             }
72536                         }
72537                         rightExpression = segment.kind === 201
72538                             ? factory.createPropertyAccessExpression(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier))
72539                             : factory.createElementAccessExpression(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression));
72540                         break;
72541                     case 203:
72542                         if (i === 0 && leftThisArg) {
72543                             rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 105 ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression));
72544                         }
72545                         else {
72546                             rightExpression = factory.createCallExpression(rightExpression, undefined, ts.visitNodes(segment.arguments, visitor, ts.isExpression));
72547                         }
72548                         break;
72549                 }
72550                 ts.setOriginalNode(rightExpression, segment);
72551             }
72552             var target = isDelete
72553                 ? factory.createConditionalExpression(createNotNullCondition(leftExpression, capturedLeft, true), undefined, factory.createTrue(), undefined, factory.createDeleteExpression(rightExpression))
72554                 : factory.createConditionalExpression(createNotNullCondition(leftExpression, capturedLeft, true), undefined, factory.createVoidZero(), undefined, rightExpression);
72555             return thisArg ? factory.createSyntheticReferenceExpression(target, thisArg) : target;
72556         }
72557         function createNotNullCondition(left, right, invert) {
72558             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()));
72559         }
72560         function transformNullishCoalescingExpression(node) {
72561             var left = ts.visitNode(node.left, visitor, ts.isExpression);
72562             var right = left;
72563             if (!ts.isSimpleCopiableExpression(left)) {
72564                 right = factory.createTempVariable(hoistVariableDeclaration);
72565                 left = factory.createAssignment(right, left);
72566             }
72567             return factory.createConditionalExpression(createNotNullCondition(left, right), undefined, right, undefined, ts.visitNode(node.right, visitor, ts.isExpression));
72568         }
72569         function visitDeleteExpression(node) {
72570             return ts.isOptionalChain(ts.skipParentheses(node.expression))
72571                 ? ts.setOriginalNode(visitNonOptionalExpression(node.expression, false, true), node)
72572                 : factory.updateDeleteExpression(node, ts.visitNode(node.expression, visitor, ts.isExpression));
72573         }
72574     }
72575     ts.transformES2020 = transformES2020;
72576 })(ts || (ts = {}));
72577 var ts;
72578 (function (ts) {
72579     function transformESNext(context) {
72580         var hoistVariableDeclaration = context.hoistVariableDeclaration, factory = context.factory;
72581         return ts.chainBundle(context, transformSourceFile);
72582         function transformSourceFile(node) {
72583             if (node.isDeclarationFile) {
72584                 return node;
72585             }
72586             return ts.visitEachChild(node, visitor, context);
72587         }
72588         function visitor(node) {
72589             if ((node.transformFlags & 4) === 0) {
72590                 return node;
72591             }
72592             switch (node.kind) {
72593                 case 216:
72594                     var binaryExpression = node;
72595                     if (ts.isLogicalOrCoalescingAssignmentExpression(binaryExpression)) {
72596                         return transformLogicalAssignment(binaryExpression);
72597                     }
72598                 default:
72599                     return ts.visitEachChild(node, visitor, context);
72600             }
72601         }
72602         function transformLogicalAssignment(binaryExpression) {
72603             var operator = binaryExpression.operatorToken;
72604             var nonAssignmentOperator = ts.getNonAssignmentOperatorForCompoundAssignment(operator.kind);
72605             var left = ts.skipParentheses(ts.visitNode(binaryExpression.left, visitor, ts.isLeftHandSideExpression));
72606             var assignmentTarget = left;
72607             var right = ts.skipParentheses(ts.visitNode(binaryExpression.right, visitor, ts.isExpression));
72608             if (ts.isAccessExpression(left)) {
72609                 var propertyAccessTargetSimpleCopiable = ts.isSimpleCopiableExpression(left.expression);
72610                 var propertyAccessTarget = propertyAccessTargetSimpleCopiable ? left.expression :
72611                     factory.createTempVariable(hoistVariableDeclaration);
72612                 var propertyAccessTargetAssignment = propertyAccessTargetSimpleCopiable ? left.expression : factory.createAssignment(propertyAccessTarget, left.expression);
72613                 if (ts.isPropertyAccessExpression(left)) {
72614                     assignmentTarget = factory.createPropertyAccessExpression(propertyAccessTarget, left.name);
72615                     left = factory.createPropertyAccessExpression(propertyAccessTargetAssignment, left.name);
72616                 }
72617                 else {
72618                     var elementAccessArgumentSimpleCopiable = ts.isSimpleCopiableExpression(left.argumentExpression);
72619                     var elementAccessArgument = elementAccessArgumentSimpleCopiable ? left.argumentExpression :
72620                         factory.createTempVariable(hoistVariableDeclaration);
72621                     assignmentTarget = factory.createElementAccessExpression(propertyAccessTarget, elementAccessArgument);
72622                     left = factory.createElementAccessExpression(propertyAccessTargetAssignment, elementAccessArgumentSimpleCopiable ? left.argumentExpression : factory.createAssignment(elementAccessArgument, left.argumentExpression));
72623                 }
72624             }
72625             return factory.createBinaryExpression(left, nonAssignmentOperator, factory.createParenthesizedExpression(factory.createAssignment(assignmentTarget, right)));
72626         }
72627     }
72628     ts.transformESNext = transformESNext;
72629 })(ts || (ts = {}));
72630 var ts;
72631 (function (ts) {
72632     function transformJsx(context) {
72633         var factory = context.factory, emitHelpers = context.getEmitHelperFactory;
72634         var compilerOptions = context.getCompilerOptions();
72635         var currentSourceFile;
72636         var currentFileState;
72637         return ts.chainBundle(context, transformSourceFile);
72638         function getCurrentFileNameExpression() {
72639             if (currentFileState.filenameDeclaration) {
72640                 return currentFileState.filenameDeclaration.name;
72641             }
72642             var declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", 16 | 32), undefined, undefined, factory.createStringLiteral(currentSourceFile.fileName));
72643             currentFileState.filenameDeclaration = declaration;
72644             return currentFileState.filenameDeclaration.name;
72645         }
72646         function getJsxFactoryCalleePrimitive(childrenLength) {
72647             return compilerOptions.jsx === 5 ? "jsxDEV" : childrenLength > 1 ? "jsxs" : "jsx";
72648         }
72649         function getJsxFactoryCallee(childrenLength) {
72650             var type = getJsxFactoryCalleePrimitive(childrenLength);
72651             return getImplicitImportForName(type);
72652         }
72653         function getImplicitJsxFragmentReference() {
72654             return getImplicitImportForName("Fragment");
72655         }
72656         function getImplicitImportForName(name) {
72657             var _a, _b;
72658             var importSource = name === "createElement"
72659                 ? currentFileState.importSpecifier
72660                 : ts.getJSXRuntimeImport(currentFileState.importSpecifier, compilerOptions);
72661             var existing = (_b = (_a = currentFileState.utilizedImplicitRuntimeImports) === null || _a === void 0 ? void 0 : _a.get(importSource)) === null || _b === void 0 ? void 0 : _b.get(name);
72662             if (existing) {
72663                 return existing.name;
72664             }
72665             if (!currentFileState.utilizedImplicitRuntimeImports) {
72666                 currentFileState.utilizedImplicitRuntimeImports = ts.createMap();
72667             }
72668             var specifierSourceImports = currentFileState.utilizedImplicitRuntimeImports.get(importSource);
72669             if (!specifierSourceImports) {
72670                 specifierSourceImports = ts.createMap();
72671                 currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports);
72672             }
72673             var generatedName = factory.createUniqueName("_" + name, 16 | 32 | 64);
72674             var specifier = factory.createImportSpecifier(factory.createIdentifier(name), generatedName);
72675             generatedName.generatedImportReference = specifier;
72676             specifierSourceImports.set(name, specifier);
72677             return generatedName;
72678         }
72679         function transformSourceFile(node) {
72680             if (node.isDeclarationFile) {
72681                 return node;
72682             }
72683             currentSourceFile = node;
72684             currentFileState = {};
72685             currentFileState.importSpecifier = ts.getJSXImplicitImportBase(compilerOptions, node);
72686             var visited = ts.visitEachChild(node, visitor, context);
72687             ts.addEmitHelpers(visited, context.readEmitHelpers());
72688             var statements = visited.statements;
72689             if (currentFileState.filenameDeclaration) {
72690                 statements = ts.insertStatementAfterCustomPrologue(statements.slice(), factory.createVariableStatement(undefined, factory.createVariableDeclarationList([currentFileState.filenameDeclaration], 2)));
72691             }
72692             if (currentFileState.utilizedImplicitRuntimeImports) {
72693                 for (var _i = 0, _a = ts.arrayFrom(currentFileState.utilizedImplicitRuntimeImports.entries()); _i < _a.length; _i++) {
72694                     var _b = _a[_i], importSource = _b[0], importSpecifiersMap = _b[1];
72695                     if (ts.isExternalModule(node)) {
72696                         var importStatement = factory.createImportDeclaration(undefined, undefined, factory.createImportClause(false, undefined, factory.createNamedImports(ts.arrayFrom(importSpecifiersMap.values()))), factory.createStringLiteral(importSource));
72697                         ts.setParentRecursive(importStatement, false);
72698                         statements = ts.insertStatementAfterCustomPrologue(statements.slice(), importStatement);
72699                     }
72700                     else if (ts.isExternalOrCommonJsModule(node)) {
72701                         var requireStatement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
72702                             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)]))
72703                         ], 2));
72704                         ts.setParentRecursive(requireStatement, false);
72705                         statements = ts.insertStatementAfterCustomPrologue(statements.slice(), requireStatement);
72706                     }
72707                     else {
72708                     }
72709                 }
72710             }
72711             if (statements !== visited.statements) {
72712                 visited = factory.updateSourceFile(visited, statements);
72713             }
72714             currentFileState = undefined;
72715             return visited;
72716         }
72717         function visitor(node) {
72718             if (node.transformFlags & 2) {
72719                 return visitorWorker(node);
72720             }
72721             else {
72722                 return node;
72723             }
72724         }
72725         function visitorWorker(node) {
72726             switch (node.kind) {
72727                 case 273:
72728                     return visitJsxElement(node, false);
72729                 case 274:
72730                     return visitJsxSelfClosingElement(node, false);
72731                 case 277:
72732                     return visitJsxFragment(node, false);
72733                 case 283:
72734                     return visitJsxExpression(node);
72735                 default:
72736                     return ts.visitEachChild(node, visitor, context);
72737             }
72738         }
72739         function transformJsxChildToExpression(node) {
72740             switch (node.kind) {
72741                 case 11:
72742                     return visitJsxText(node);
72743                 case 283:
72744                     return visitJsxExpression(node);
72745                 case 273:
72746                     return visitJsxElement(node, true);
72747                 case 274:
72748                     return visitJsxSelfClosingElement(node, true);
72749                 case 277:
72750                     return visitJsxFragment(node, true);
72751                 default:
72752                     return ts.Debug.failBadSyntaxKind(node);
72753             }
72754         }
72755         function hasKeyAfterPropsSpread(node) {
72756             var spread = false;
72757             for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) {
72758                 var elem = _a[_i];
72759                 if (ts.isJsxSpreadAttribute(elem)) {
72760                     spread = true;
72761                 }
72762                 else if (spread && ts.isJsxAttribute(elem) && elem.name.escapedText === "key") {
72763                     return true;
72764                 }
72765             }
72766             return false;
72767         }
72768         function shouldUseCreateElement(node) {
72769             return currentFileState.importSpecifier === undefined || hasKeyAfterPropsSpread(node);
72770         }
72771         function visitJsxElement(node, isChild) {
72772             var tagTransform = shouldUseCreateElement(node.openingElement) ? visitJsxOpeningLikeElementCreateElement : visitJsxOpeningLikeElementJSX;
72773             return tagTransform(node.openingElement, node.children, isChild, node);
72774         }
72775         function visitJsxSelfClosingElement(node, isChild) {
72776             var tagTransform = shouldUseCreateElement(node) ? visitJsxOpeningLikeElementCreateElement : visitJsxOpeningLikeElementJSX;
72777             return tagTransform(node, undefined, isChild, node);
72778         }
72779         function visitJsxFragment(node, isChild) {
72780             var tagTransform = currentFileState.importSpecifier === undefined ? visitJsxOpeningFragmentCreateElement : visitJsxOpeningFragmentJSX;
72781             return tagTransform(node.openingFragment, node.children, isChild, node);
72782         }
72783         function convertJsxChildrenToChildrenPropObject(children) {
72784             var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
72785             if (ts.length(nonWhitespaceChildren) === 1) {
72786                 var result_13 = transformJsxChildToExpression(nonWhitespaceChildren[0]);
72787                 return result_13 && factory.createObjectLiteralExpression([
72788                     factory.createPropertyAssignment("children", result_13)
72789                 ]);
72790             }
72791             var result = ts.mapDefined(children, transformJsxChildToExpression);
72792             return !result.length ? undefined : factory.createObjectLiteralExpression([
72793                 factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result))
72794             ]);
72795         }
72796         function visitJsxOpeningLikeElementJSX(node, children, isChild, location) {
72797             var tagName = getTagName(node);
72798             var objectProperties;
72799             var keyAttr = ts.find(node.attributes.properties, function (p) { return !!p.name && ts.isIdentifier(p.name) && p.name.escapedText === "key"; });
72800             var attrs = keyAttr ? ts.filter(node.attributes.properties, function (p) { return p !== keyAttr; }) : node.attributes.properties;
72801             var segments = [];
72802             if (attrs.length) {
72803                 segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread
72804                     ? ts.map(attrs, transformJsxSpreadAttributeToExpression)
72805                     : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); }));
72806                 if (ts.isJsxSpreadAttribute(attrs[0])) {
72807                     segments.unshift(factory.createObjectLiteralExpression());
72808                 }
72809             }
72810             if (children && children.length) {
72811                 var result = convertJsxChildrenToChildrenPropObject(children);
72812                 if (result) {
72813                     segments.push(result);
72814                 }
72815             }
72816             if (segments.length === 0) {
72817                 objectProperties = factory.createObjectLiteralExpression([]);
72818             }
72819             else {
72820                 objectProperties = ts.singleOrUndefined(segments) || emitHelpers().createAssignHelper(segments);
72821             }
72822             return visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, ts.length(ts.getSemanticJsxChildren(children || ts.emptyArray)), isChild, location);
72823         }
72824         function visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, childrenLength, isChild, location) {
72825             var args = [tagName, objectProperties, !keyAttr ? factory.createVoidZero() : transformJsxAttributeInitializer(keyAttr.initializer)];
72826             if (compilerOptions.jsx === 5) {
72827                 var originalFile = ts.getOriginalNode(currentSourceFile);
72828                 if (originalFile && ts.isSourceFile(originalFile)) {
72829                     args.push(childrenLength > 1 ? factory.createTrue() : factory.createFalse());
72830                     var lineCol = ts.getLineAndCharacterOfPosition(originalFile, location.pos);
72831                     args.push(factory.createObjectLiteralExpression([
72832                         factory.createPropertyAssignment("fileName", getCurrentFileNameExpression()),
72833                         factory.createPropertyAssignment("lineNumber", factory.createNumericLiteral(lineCol.line + 1)),
72834                         factory.createPropertyAssignment("columnNumber", factory.createNumericLiteral(lineCol.character + 1))
72835                     ]));
72836                     args.push(factory.createThis());
72837                 }
72838             }
72839             var element = ts.setTextRange(factory.createCallExpression(getJsxFactoryCallee(childrenLength), undefined, args), location);
72840             if (isChild) {
72841                 ts.startOnNewLine(element);
72842             }
72843             return element;
72844         }
72845         function visitJsxOpeningLikeElementCreateElement(node, children, isChild, location) {
72846             var tagName = getTagName(node);
72847             var objectProperties;
72848             var attrs = node.attributes.properties;
72849             if (attrs.length === 0) {
72850                 objectProperties = factory.createNull();
72851             }
72852             else {
72853                 var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread
72854                     ? ts.map(attrs, transformJsxSpreadAttributeToExpression)
72855                     : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); }));
72856                 if (ts.isJsxSpreadAttribute(attrs[0])) {
72857                     segments.unshift(factory.createObjectLiteralExpression());
72858                 }
72859                 objectProperties = ts.singleOrUndefined(segments);
72860                 if (!objectProperties) {
72861                     objectProperties = emitHelpers().createAssignHelper(segments);
72862                 }
72863             }
72864             var callee = currentFileState.importSpecifier === undefined
72865                 ? ts.createJsxFactoryExpression(factory, context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, node)
72866                 : getImplicitImportForName("createElement");
72867             var element = ts.createExpressionForJsxElement(factory, callee, tagName, objectProperties, ts.mapDefined(children, transformJsxChildToExpression), location);
72868             if (isChild) {
72869                 ts.startOnNewLine(element);
72870             }
72871             return element;
72872         }
72873         function visitJsxOpeningFragmentJSX(_node, children, isChild, location) {
72874             var childrenProps;
72875             if (children && children.length) {
72876                 var result = convertJsxChildrenToChildrenPropObject(children);
72877                 if (result) {
72878                     childrenProps = result;
72879                 }
72880             }
72881             return visitJsxOpeningLikeElementOrFragmentJSX(getImplicitJsxFragmentReference(), childrenProps || factory.createObjectLiteralExpression([]), undefined, ts.length(ts.getSemanticJsxChildren(children)), isChild, location);
72882         }
72883         function visitJsxOpeningFragmentCreateElement(node, children, isChild, location) {
72884             var element = ts.createExpressionForJsxFragment(factory, context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), context.getEmitResolver().getJsxFragmentFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, ts.mapDefined(children, transformJsxChildToExpression), node, location);
72885             if (isChild) {
72886                 ts.startOnNewLine(element);
72887             }
72888             return element;
72889         }
72890         function transformJsxSpreadAttributeToExpression(node) {
72891             return ts.visitNode(node.expression, visitor, ts.isExpression);
72892         }
72893         function transformJsxAttributeToObjectLiteralElement(node) {
72894             var name = getAttributeName(node);
72895             var expression = transformJsxAttributeInitializer(node.initializer);
72896             return factory.createPropertyAssignment(name, expression);
72897         }
72898         function transformJsxAttributeInitializer(node) {
72899             if (node === undefined) {
72900                 return factory.createTrue();
72901             }
72902             else if (node.kind === 10) {
72903                 var singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile);
72904                 var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote);
72905                 return ts.setTextRange(literal, node);
72906             }
72907             else if (node.kind === 283) {
72908                 if (node.expression === undefined) {
72909                     return factory.createTrue();
72910                 }
72911                 return ts.visitNode(node.expression, visitor, ts.isExpression);
72912             }
72913             else {
72914                 return ts.Debug.failBadSyntaxKind(node);
72915             }
72916         }
72917         function visitJsxText(node) {
72918             var fixed = fixupWhitespaceAndDecodeEntities(node.text);
72919             return fixed === undefined ? undefined : factory.createStringLiteral(fixed);
72920         }
72921         function fixupWhitespaceAndDecodeEntities(text) {
72922             var acc;
72923             var firstNonWhitespace = 0;
72924             var lastNonWhitespace = -1;
72925             for (var i = 0; i < text.length; i++) {
72926                 var c = text.charCodeAt(i);
72927                 if (ts.isLineBreak(c)) {
72928                     if (firstNonWhitespace !== -1 && lastNonWhitespace !== -1) {
72929                         acc = addLineOfJsxText(acc, text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1));
72930                     }
72931                     firstNonWhitespace = -1;
72932                 }
72933                 else if (!ts.isWhiteSpaceSingleLine(c)) {
72934                     lastNonWhitespace = i;
72935                     if (firstNonWhitespace === -1) {
72936                         firstNonWhitespace = i;
72937                     }
72938                 }
72939             }
72940             return firstNonWhitespace !== -1
72941                 ? addLineOfJsxText(acc, text.substr(firstNonWhitespace))
72942                 : acc;
72943         }
72944         function addLineOfJsxText(acc, trimmedLine) {
72945             var decoded = decodeEntities(trimmedLine);
72946             return acc === undefined ? decoded : acc + " " + decoded;
72947         }
72948         function decodeEntities(text) {
72949             return text.replace(/&((#((\d+)|x([\da-fA-F]+)))|(\w+));/g, function (match, _all, _number, _digits, decimal, hex, word) {
72950                 if (decimal) {
72951                     return ts.utf16EncodeAsString(parseInt(decimal, 10));
72952                 }
72953                 else if (hex) {
72954                     return ts.utf16EncodeAsString(parseInt(hex, 16));
72955                 }
72956                 else {
72957                     var ch = entities.get(word);
72958                     return ch ? ts.utf16EncodeAsString(ch) : match;
72959                 }
72960             });
72961         }
72962         function tryDecodeEntities(text) {
72963             var decoded = decodeEntities(text);
72964             return decoded === text ? undefined : decoded;
72965         }
72966         function getTagName(node) {
72967             if (node.kind === 273) {
72968                 return getTagName(node.openingElement);
72969             }
72970             else {
72971                 var name = node.tagName;
72972                 if (ts.isIdentifier(name) && ts.isIntrinsicJsxName(name.escapedText)) {
72973                     return factory.createStringLiteral(ts.idText(name));
72974                 }
72975                 else {
72976                     return ts.createExpressionFromEntityName(factory, name);
72977                 }
72978             }
72979         }
72980         function getAttributeName(node) {
72981             var name = node.name;
72982             var text = ts.idText(name);
72983             if (/^[A-Za-z_]\w*$/.test(text)) {
72984                 return name;
72985             }
72986             else {
72987                 return factory.createStringLiteral(text);
72988             }
72989         }
72990         function visitJsxExpression(node) {
72991             return ts.visitNode(node.expression, visitor, ts.isExpression);
72992         }
72993     }
72994     ts.transformJsx = transformJsx;
72995     var entities = new ts.Map(ts.getEntries({
72996         quot: 0x0022,
72997         amp: 0x0026,
72998         apos: 0x0027,
72999         lt: 0x003C,
73000         gt: 0x003E,
73001         nbsp: 0x00A0,
73002         iexcl: 0x00A1,
73003         cent: 0x00A2,
73004         pound: 0x00A3,
73005         curren: 0x00A4,
73006         yen: 0x00A5,
73007         brvbar: 0x00A6,
73008         sect: 0x00A7,
73009         uml: 0x00A8,
73010         copy: 0x00A9,
73011         ordf: 0x00AA,
73012         laquo: 0x00AB,
73013         not: 0x00AC,
73014         shy: 0x00AD,
73015         reg: 0x00AE,
73016         macr: 0x00AF,
73017         deg: 0x00B0,
73018         plusmn: 0x00B1,
73019         sup2: 0x00B2,
73020         sup3: 0x00B3,
73021         acute: 0x00B4,
73022         micro: 0x00B5,
73023         para: 0x00B6,
73024         middot: 0x00B7,
73025         cedil: 0x00B8,
73026         sup1: 0x00B9,
73027         ordm: 0x00BA,
73028         raquo: 0x00BB,
73029         frac14: 0x00BC,
73030         frac12: 0x00BD,
73031         frac34: 0x00BE,
73032         iquest: 0x00BF,
73033         Agrave: 0x00C0,
73034         Aacute: 0x00C1,
73035         Acirc: 0x00C2,
73036         Atilde: 0x00C3,
73037         Auml: 0x00C4,
73038         Aring: 0x00C5,
73039         AElig: 0x00C6,
73040         Ccedil: 0x00C7,
73041         Egrave: 0x00C8,
73042         Eacute: 0x00C9,
73043         Ecirc: 0x00CA,
73044         Euml: 0x00CB,
73045         Igrave: 0x00CC,
73046         Iacute: 0x00CD,
73047         Icirc: 0x00CE,
73048         Iuml: 0x00CF,
73049         ETH: 0x00D0,
73050         Ntilde: 0x00D1,
73051         Ograve: 0x00D2,
73052         Oacute: 0x00D3,
73053         Ocirc: 0x00D4,
73054         Otilde: 0x00D5,
73055         Ouml: 0x00D6,
73056         times: 0x00D7,
73057         Oslash: 0x00D8,
73058         Ugrave: 0x00D9,
73059         Uacute: 0x00DA,
73060         Ucirc: 0x00DB,
73061         Uuml: 0x00DC,
73062         Yacute: 0x00DD,
73063         THORN: 0x00DE,
73064         szlig: 0x00DF,
73065         agrave: 0x00E0,
73066         aacute: 0x00E1,
73067         acirc: 0x00E2,
73068         atilde: 0x00E3,
73069         auml: 0x00E4,
73070         aring: 0x00E5,
73071         aelig: 0x00E6,
73072         ccedil: 0x00E7,
73073         egrave: 0x00E8,
73074         eacute: 0x00E9,
73075         ecirc: 0x00EA,
73076         euml: 0x00EB,
73077         igrave: 0x00EC,
73078         iacute: 0x00ED,
73079         icirc: 0x00EE,
73080         iuml: 0x00EF,
73081         eth: 0x00F0,
73082         ntilde: 0x00F1,
73083         ograve: 0x00F2,
73084         oacute: 0x00F3,
73085         ocirc: 0x00F4,
73086         otilde: 0x00F5,
73087         ouml: 0x00F6,
73088         divide: 0x00F7,
73089         oslash: 0x00F8,
73090         ugrave: 0x00F9,
73091         uacute: 0x00FA,
73092         ucirc: 0x00FB,
73093         uuml: 0x00FC,
73094         yacute: 0x00FD,
73095         thorn: 0x00FE,
73096         yuml: 0x00FF,
73097         OElig: 0x0152,
73098         oelig: 0x0153,
73099         Scaron: 0x0160,
73100         scaron: 0x0161,
73101         Yuml: 0x0178,
73102         fnof: 0x0192,
73103         circ: 0x02C6,
73104         tilde: 0x02DC,
73105         Alpha: 0x0391,
73106         Beta: 0x0392,
73107         Gamma: 0x0393,
73108         Delta: 0x0394,
73109         Epsilon: 0x0395,
73110         Zeta: 0x0396,
73111         Eta: 0x0397,
73112         Theta: 0x0398,
73113         Iota: 0x0399,
73114         Kappa: 0x039A,
73115         Lambda: 0x039B,
73116         Mu: 0x039C,
73117         Nu: 0x039D,
73118         Xi: 0x039E,
73119         Omicron: 0x039F,
73120         Pi: 0x03A0,
73121         Rho: 0x03A1,
73122         Sigma: 0x03A3,
73123         Tau: 0x03A4,
73124         Upsilon: 0x03A5,
73125         Phi: 0x03A6,
73126         Chi: 0x03A7,
73127         Psi: 0x03A8,
73128         Omega: 0x03A9,
73129         alpha: 0x03B1,
73130         beta: 0x03B2,
73131         gamma: 0x03B3,
73132         delta: 0x03B4,
73133         epsilon: 0x03B5,
73134         zeta: 0x03B6,
73135         eta: 0x03B7,
73136         theta: 0x03B8,
73137         iota: 0x03B9,
73138         kappa: 0x03BA,
73139         lambda: 0x03BB,
73140         mu: 0x03BC,
73141         nu: 0x03BD,
73142         xi: 0x03BE,
73143         omicron: 0x03BF,
73144         pi: 0x03C0,
73145         rho: 0x03C1,
73146         sigmaf: 0x03C2,
73147         sigma: 0x03C3,
73148         tau: 0x03C4,
73149         upsilon: 0x03C5,
73150         phi: 0x03C6,
73151         chi: 0x03C7,
73152         psi: 0x03C8,
73153         omega: 0x03C9,
73154         thetasym: 0x03D1,
73155         upsih: 0x03D2,
73156         piv: 0x03D6,
73157         ensp: 0x2002,
73158         emsp: 0x2003,
73159         thinsp: 0x2009,
73160         zwnj: 0x200C,
73161         zwj: 0x200D,
73162         lrm: 0x200E,
73163         rlm: 0x200F,
73164         ndash: 0x2013,
73165         mdash: 0x2014,
73166         lsquo: 0x2018,
73167         rsquo: 0x2019,
73168         sbquo: 0x201A,
73169         ldquo: 0x201C,
73170         rdquo: 0x201D,
73171         bdquo: 0x201E,
73172         dagger: 0x2020,
73173         Dagger: 0x2021,
73174         bull: 0x2022,
73175         hellip: 0x2026,
73176         permil: 0x2030,
73177         prime: 0x2032,
73178         Prime: 0x2033,
73179         lsaquo: 0x2039,
73180         rsaquo: 0x203A,
73181         oline: 0x203E,
73182         frasl: 0x2044,
73183         euro: 0x20AC,
73184         image: 0x2111,
73185         weierp: 0x2118,
73186         real: 0x211C,
73187         trade: 0x2122,
73188         alefsym: 0x2135,
73189         larr: 0x2190,
73190         uarr: 0x2191,
73191         rarr: 0x2192,
73192         darr: 0x2193,
73193         harr: 0x2194,
73194         crarr: 0x21B5,
73195         lArr: 0x21D0,
73196         uArr: 0x21D1,
73197         rArr: 0x21D2,
73198         dArr: 0x21D3,
73199         hArr: 0x21D4,
73200         forall: 0x2200,
73201         part: 0x2202,
73202         exist: 0x2203,
73203         empty: 0x2205,
73204         nabla: 0x2207,
73205         isin: 0x2208,
73206         notin: 0x2209,
73207         ni: 0x220B,
73208         prod: 0x220F,
73209         sum: 0x2211,
73210         minus: 0x2212,
73211         lowast: 0x2217,
73212         radic: 0x221A,
73213         prop: 0x221D,
73214         infin: 0x221E,
73215         ang: 0x2220,
73216         and: 0x2227,
73217         or: 0x2228,
73218         cap: 0x2229,
73219         cup: 0x222A,
73220         int: 0x222B,
73221         there4: 0x2234,
73222         sim: 0x223C,
73223         cong: 0x2245,
73224         asymp: 0x2248,
73225         ne: 0x2260,
73226         equiv: 0x2261,
73227         le: 0x2264,
73228         ge: 0x2265,
73229         sub: 0x2282,
73230         sup: 0x2283,
73231         nsub: 0x2284,
73232         sube: 0x2286,
73233         supe: 0x2287,
73234         oplus: 0x2295,
73235         otimes: 0x2297,
73236         perp: 0x22A5,
73237         sdot: 0x22C5,
73238         lceil: 0x2308,
73239         rceil: 0x2309,
73240         lfloor: 0x230A,
73241         rfloor: 0x230B,
73242         lang: 0x2329,
73243         rang: 0x232A,
73244         loz: 0x25CA,
73245         spades: 0x2660,
73246         clubs: 0x2663,
73247         hearts: 0x2665,
73248         diams: 0x2666
73249     }));
73250 })(ts || (ts = {}));
73251 var ts;
73252 (function (ts) {
73253     function transformES2016(context) {
73254         var factory = context.factory, hoistVariableDeclaration = context.hoistVariableDeclaration;
73255         return ts.chainBundle(context, transformSourceFile);
73256         function transformSourceFile(node) {
73257             if (node.isDeclarationFile) {
73258                 return node;
73259             }
73260             return ts.visitEachChild(node, visitor, context);
73261         }
73262         function visitor(node) {
73263             if ((node.transformFlags & 128) === 0) {
73264                 return node;
73265             }
73266             switch (node.kind) {
73267                 case 216:
73268                     return visitBinaryExpression(node);
73269                 default:
73270                     return ts.visitEachChild(node, visitor, context);
73271             }
73272         }
73273         function visitBinaryExpression(node) {
73274             switch (node.operatorToken.kind) {
73275                 case 66:
73276                     return visitExponentiationAssignmentExpression(node);
73277                 case 42:
73278                     return visitExponentiationExpression(node);
73279                 default:
73280                     return ts.visitEachChild(node, visitor, context);
73281             }
73282         }
73283         function visitExponentiationAssignmentExpression(node) {
73284             var target;
73285             var value;
73286             var left = ts.visitNode(node.left, visitor, ts.isExpression);
73287             var right = ts.visitNode(node.right, visitor, ts.isExpression);
73288             if (ts.isElementAccessExpression(left)) {
73289                 var expressionTemp = factory.createTempVariable(hoistVariableDeclaration);
73290                 var argumentExpressionTemp = factory.createTempVariable(hoistVariableDeclaration);
73291                 target = ts.setTextRange(factory.createElementAccessExpression(ts.setTextRange(factory.createAssignment(expressionTemp, left.expression), left.expression), ts.setTextRange(factory.createAssignment(argumentExpressionTemp, left.argumentExpression), left.argumentExpression)), left);
73292                 value = ts.setTextRange(factory.createElementAccessExpression(expressionTemp, argumentExpressionTemp), left);
73293             }
73294             else if (ts.isPropertyAccessExpression(left)) {
73295                 var expressionTemp = factory.createTempVariable(hoistVariableDeclaration);
73296                 target = ts.setTextRange(factory.createPropertyAccessExpression(ts.setTextRange(factory.createAssignment(expressionTemp, left.expression), left.expression), left.name), left);
73297                 value = ts.setTextRange(factory.createPropertyAccessExpression(expressionTemp, left.name), left);
73298             }
73299             else {
73300                 target = left;
73301                 value = left;
73302             }
73303             return ts.setTextRange(factory.createAssignment(target, ts.setTextRange(factory.createGlobalMethodCall("Math", "pow", [value, right]), node)), node);
73304         }
73305         function visitExponentiationExpression(node) {
73306             var left = ts.visitNode(node.left, visitor, ts.isExpression);
73307             var right = ts.visitNode(node.right, visitor, ts.isExpression);
73308             return ts.setTextRange(factory.createGlobalMethodCall("Math", "pow", [left, right]), node);
73309         }
73310     }
73311     ts.transformES2016 = transformES2016;
73312 })(ts || (ts = {}));
73313 var ts;
73314 (function (ts) {
73315     function transformES2015(context) {
73316         var factory = context.factory, emitHelpers = context.getEmitHelperFactory, startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
73317         var compilerOptions = context.getCompilerOptions();
73318         var resolver = context.getEmitResolver();
73319         var previousOnSubstituteNode = context.onSubstituteNode;
73320         var previousOnEmitNode = context.onEmitNode;
73321         context.onEmitNode = onEmitNode;
73322         context.onSubstituteNode = onSubstituteNode;
73323         var currentSourceFile;
73324         var currentText;
73325         var hierarchyFacts;
73326         var taggedTemplateStringDeclarations;
73327         function recordTaggedTemplateString(temp) {
73328             taggedTemplateStringDeclarations = ts.append(taggedTemplateStringDeclarations, factory.createVariableDeclaration(temp));
73329         }
73330         var convertedLoopState;
73331         var enabledSubstitutions;
73332         return ts.chainBundle(context, transformSourceFile);
73333         function transformSourceFile(node) {
73334             if (node.isDeclarationFile) {
73335                 return node;
73336             }
73337             currentSourceFile = node;
73338             currentText = node.text;
73339             var visited = visitSourceFile(node);
73340             ts.addEmitHelpers(visited, context.readEmitHelpers());
73341             currentSourceFile = undefined;
73342             currentText = undefined;
73343             taggedTemplateStringDeclarations = undefined;
73344             hierarchyFacts = 0;
73345             return visited;
73346         }
73347         function enterSubtree(excludeFacts, includeFacts) {
73348             var ancestorFacts = hierarchyFacts;
73349             hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383;
73350             return ancestorFacts;
73351         }
73352         function exitSubtree(ancestorFacts, excludeFacts, includeFacts) {
73353             hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 | ancestorFacts;
73354         }
73355         function isReturnVoidStatementInConstructorWithCapturedSuper(node) {
73356             return (hierarchyFacts & 8192) !== 0
73357                 && node.kind === 242
73358                 && !node.expression;
73359         }
73360         function isOrMayContainReturnCompletion(node) {
73361             return node.transformFlags & 1048576
73362                 && (ts.isReturnStatement(node)
73363                     || ts.isIfStatement(node)
73364                     || ts.isWithStatement(node)
73365                     || ts.isSwitchStatement(node)
73366                     || ts.isCaseBlock(node)
73367                     || ts.isCaseClause(node)
73368                     || ts.isDefaultClause(node)
73369                     || ts.isTryStatement(node)
73370                     || ts.isCatchClause(node)
73371                     || ts.isLabeledStatement(node)
73372                     || ts.isIterationStatement(node, false)
73373                     || ts.isBlock(node));
73374         }
73375         function shouldVisitNode(node) {
73376             return (node.transformFlags & 256) !== 0
73377                 || convertedLoopState !== undefined
73378                 || (hierarchyFacts & 8192 && isOrMayContainReturnCompletion(node))
73379                 || (ts.isIterationStatement(node, false) && shouldConvertIterationStatement(node))
73380                 || (ts.getEmitFlags(node) & 33554432) !== 0;
73381         }
73382         function visitor(node) {
73383             return shouldVisitNode(node) ? visitorWorker(node, false) : node;
73384         }
73385         function visitorWithUnusedExpressionResult(node) {
73386             return shouldVisitNode(node) ? visitorWorker(node, true) : node;
73387         }
73388         function callExpressionVisitor(node) {
73389             if (node.kind === 105) {
73390                 return visitSuperKeyword(true);
73391             }
73392             return visitor(node);
73393         }
73394         function visitorWorker(node, expressionResultIsUnused) {
73395             switch (node.kind) {
73396                 case 123:
73397                     return undefined;
73398                 case 252:
73399                     return visitClassDeclaration(node);
73400                 case 221:
73401                     return visitClassExpression(node);
73402                 case 160:
73403                     return visitParameter(node);
73404                 case 251:
73405                     return visitFunctionDeclaration(node);
73406                 case 209:
73407                     return visitArrowFunction(node);
73408                 case 208:
73409                     return visitFunctionExpression(node);
73410                 case 249:
73411                     return visitVariableDeclaration(node);
73412                 case 78:
73413                     return visitIdentifier(node);
73414                 case 250:
73415                     return visitVariableDeclarationList(node);
73416                 case 244:
73417                     return visitSwitchStatement(node);
73418                 case 258:
73419                     return visitCaseBlock(node);
73420                 case 230:
73421                     return visitBlock(node, false);
73422                 case 241:
73423                 case 240:
73424                     return visitBreakOrContinueStatement(node);
73425                 case 245:
73426                     return visitLabeledStatement(node);
73427                 case 235:
73428                 case 236:
73429                     return visitDoOrWhileStatement(node, undefined);
73430                 case 237:
73431                     return visitForStatement(node, undefined);
73432                 case 238:
73433                     return visitForInStatement(node, undefined);
73434                 case 239:
73435                     return visitForOfStatement(node, undefined);
73436                 case 233:
73437                     return visitExpressionStatement(node);
73438                 case 200:
73439                     return visitObjectLiteralExpression(node);
73440                 case 287:
73441                     return visitCatchClause(node);
73442                 case 289:
73443                     return visitShorthandPropertyAssignment(node);
73444                 case 158:
73445                     return visitComputedPropertyName(node);
73446                 case 199:
73447                     return visitArrayLiteralExpression(node);
73448                 case 203:
73449                     return visitCallExpression(node);
73450                 case 204:
73451                     return visitNewExpression(node);
73452                 case 207:
73453                     return visitParenthesizedExpression(node, expressionResultIsUnused);
73454                 case 216:
73455                     return visitBinaryExpression(node, expressionResultIsUnused);
73456                 case 337:
73457                     return visitCommaListExpression(node, expressionResultIsUnused);
73458                 case 14:
73459                 case 15:
73460                 case 16:
73461                 case 17:
73462                     return visitTemplateLiteral(node);
73463                 case 10:
73464                     return visitStringLiteral(node);
73465                 case 8:
73466                     return visitNumericLiteral(node);
73467                 case 205:
73468                     return visitTaggedTemplateExpression(node);
73469                 case 218:
73470                     return visitTemplateExpression(node);
73471                 case 219:
73472                     return visitYieldExpression(node);
73473                 case 220:
73474                     return visitSpreadElement(node);
73475                 case 105:
73476                     return visitSuperKeyword(false);
73477                 case 107:
73478                     return visitThisKeyword(node);
73479                 case 226:
73480                     return visitMetaProperty(node);
73481                 case 165:
73482                     return visitMethodDeclaration(node);
73483                 case 167:
73484                 case 168:
73485                     return visitAccessorDeclaration(node);
73486                 case 232:
73487                     return visitVariableStatement(node);
73488                 case 242:
73489                     return visitReturnStatement(node);
73490                 case 212:
73491                     return visitVoidExpression(node);
73492                 default:
73493                     return ts.visitEachChild(node, visitor, context);
73494             }
73495         }
73496         function visitSourceFile(node) {
73497             var ancestorFacts = enterSubtree(8064, 64);
73498             var prologue = [];
73499             var statements = [];
73500             startLexicalEnvironment();
73501             var statementOffset = factory.copyPrologue(node.statements, prologue, false, visitor);
73502             ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset));
73503             if (taggedTemplateStringDeclarations) {
73504                 statements.push(factory.createVariableStatement(undefined, factory.createVariableDeclarationList(taggedTemplateStringDeclarations)));
73505             }
73506             factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
73507             insertCaptureThisForNodeIfNeeded(prologue, node);
73508             exitSubtree(ancestorFacts, 0, 0);
73509             return factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray(ts.concatenate(prologue, statements)), node.statements));
73510         }
73511         function visitSwitchStatement(node) {
73512             if (convertedLoopState !== undefined) {
73513                 var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps;
73514                 convertedLoopState.allowedNonLabeledJumps |= 2;
73515                 var result = ts.visitEachChild(node, visitor, context);
73516                 convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps;
73517                 return result;
73518             }
73519             return ts.visitEachChild(node, visitor, context);
73520         }
73521         function visitCaseBlock(node) {
73522             var ancestorFacts = enterSubtree(7104, 0);
73523             var updated = ts.visitEachChild(node, visitor, context);
73524             exitSubtree(ancestorFacts, 0, 0);
73525             return updated;
73526         }
73527         function returnCapturedThis(node) {
73528             return ts.setOriginalNode(factory.createReturnStatement(factory.createUniqueName("_this", 16 | 32)), node);
73529         }
73530         function visitReturnStatement(node) {
73531             if (convertedLoopState) {
73532                 convertedLoopState.nonLocalJumps |= 8;
73533                 if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) {
73534                     node = returnCapturedThis(node);
73535                 }
73536                 return factory.createReturnStatement(factory.createObjectLiteralExpression([
73537                     factory.createPropertyAssignment(factory.createIdentifier("value"), node.expression
73538                         ? ts.visitNode(node.expression, visitor, ts.isExpression)
73539                         : factory.createVoidZero())
73540                 ]));
73541             }
73542             else if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) {
73543                 return returnCapturedThis(node);
73544             }
73545             return ts.visitEachChild(node, visitor, context);
73546         }
73547         function visitThisKeyword(node) {
73548             if (hierarchyFacts & 2) {
73549                 hierarchyFacts |= 32768;
73550             }
73551             if (convertedLoopState) {
73552                 if (hierarchyFacts & 2) {
73553                     convertedLoopState.containsLexicalThis = true;
73554                     return node;
73555                 }
73556                 return convertedLoopState.thisName || (convertedLoopState.thisName = factory.createUniqueName("this"));
73557             }
73558             return node;
73559         }
73560         function visitVoidExpression(node) {
73561             return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
73562         }
73563         function visitIdentifier(node) {
73564             if (!convertedLoopState) {
73565                 return node;
73566             }
73567             if (resolver.isArgumentsLocalBinding(node)) {
73568                 return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = factory.createUniqueName("arguments"));
73569             }
73570             return node;
73571         }
73572         function visitBreakOrContinueStatement(node) {
73573             if (convertedLoopState) {
73574                 var jump = node.kind === 241 ? 2 : 4;
73575                 var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) ||
73576                     (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump));
73577                 if (!canUseBreakOrContinue) {
73578                     var labelMarker = void 0;
73579                     var label = node.label;
73580                     if (!label) {
73581                         if (node.kind === 241) {
73582                             convertedLoopState.nonLocalJumps |= 2;
73583                             labelMarker = "break";
73584                         }
73585                         else {
73586                             convertedLoopState.nonLocalJumps |= 4;
73587                             labelMarker = "continue";
73588                         }
73589                     }
73590                     else {
73591                         if (node.kind === 241) {
73592                             labelMarker = "break-" + label.escapedText;
73593                             setLabeledJump(convertedLoopState, true, ts.idText(label), labelMarker);
73594                         }
73595                         else {
73596                             labelMarker = "continue-" + label.escapedText;
73597                             setLabeledJump(convertedLoopState, false, ts.idText(label), labelMarker);
73598                         }
73599                     }
73600                     var returnExpression = factory.createStringLiteral(labelMarker);
73601                     if (convertedLoopState.loopOutParameters.length) {
73602                         var outParams = convertedLoopState.loopOutParameters;
73603                         var expr = void 0;
73604                         for (var i = 0; i < outParams.length; i++) {
73605                             var copyExpr = copyOutParameter(outParams[i], 1);
73606                             if (i === 0) {
73607                                 expr = copyExpr;
73608                             }
73609                             else {
73610                                 expr = factory.createBinaryExpression(expr, 27, copyExpr);
73611                             }
73612                         }
73613                         returnExpression = factory.createBinaryExpression(expr, 27, returnExpression);
73614                     }
73615                     return factory.createReturnStatement(returnExpression);
73616                 }
73617             }
73618             return ts.visitEachChild(node, visitor, context);
73619         }
73620         function visitClassDeclaration(node) {
73621             var variable = factory.createVariableDeclaration(factory.getLocalName(node, true), undefined, undefined, transformClassLikeDeclarationToExpression(node));
73622             ts.setOriginalNode(variable, node);
73623             var statements = [];
73624             var statement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([variable]));
73625             ts.setOriginalNode(statement, node);
73626             ts.setTextRange(statement, node);
73627             ts.startOnNewLine(statement);
73628             statements.push(statement);
73629             if (ts.hasSyntacticModifier(node, 1)) {
73630                 var exportStatement = ts.hasSyntacticModifier(node, 512)
73631                     ? factory.createExportDefault(factory.getLocalName(node))
73632                     : factory.createExternalModuleExport(factory.getLocalName(node));
73633                 ts.setOriginalNode(exportStatement, statement);
73634                 statements.push(exportStatement);
73635             }
73636             var emitFlags = ts.getEmitFlags(node);
73637             if ((emitFlags & 4194304) === 0) {
73638                 statements.push(factory.createEndOfDeclarationMarker(node));
73639                 ts.setEmitFlags(statement, emitFlags | 4194304);
73640             }
73641             return ts.singleOrMany(statements);
73642         }
73643         function visitClassExpression(node) {
73644             return transformClassLikeDeclarationToExpression(node);
73645         }
73646         function transformClassLikeDeclarationToExpression(node) {
73647             if (node.name) {
73648                 enableSubstitutionsForBlockScopedBindings();
73649             }
73650             var extendsClauseElement = ts.getClassExtendsHeritageElement(node);
73651             var classFunction = factory.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [factory.createParameterDeclaration(undefined, undefined, undefined, factory.createUniqueName("_super", 16 | 32))] : [], undefined, transformClassBody(node, extendsClauseElement));
73652             ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536) | 524288);
73653             var inner = factory.createPartiallyEmittedExpression(classFunction);
73654             ts.setTextRangeEnd(inner, node.end);
73655             ts.setEmitFlags(inner, 1536);
73656             var outer = factory.createPartiallyEmittedExpression(inner);
73657             ts.setTextRangeEnd(outer, ts.skipTrivia(currentText, node.pos));
73658             ts.setEmitFlags(outer, 1536);
73659             var result = factory.createParenthesizedExpression(factory.createCallExpression(outer, undefined, extendsClauseElement
73660                 ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)]
73661                 : []));
73662             ts.addSyntheticLeadingComment(result, 3, "* @class ");
73663             return result;
73664         }
73665         function transformClassBody(node, extendsClauseElement) {
73666             var statements = [];
73667             var name = factory.getInternalName(node);
73668             var constructorLikeName = ts.isIdentifierANonContextualKeyword(name) ? factory.getGeneratedNameForNode(name) : name;
73669             startLexicalEnvironment();
73670             addExtendsHelperIfNeeded(statements, node, extendsClauseElement);
73671             addConstructor(statements, node, constructorLikeName, extendsClauseElement);
73672             addClassMembers(statements, node);
73673             var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19);
73674             var outer = factory.createPartiallyEmittedExpression(constructorLikeName);
73675             ts.setTextRangeEnd(outer, closingBraceLocation.end);
73676             ts.setEmitFlags(outer, 1536);
73677             var statement = factory.createReturnStatement(outer);
73678             ts.setTextRangePos(statement, closingBraceLocation.pos);
73679             ts.setEmitFlags(statement, 1536 | 384);
73680             statements.push(statement);
73681             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
73682             var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), node.members), true);
73683             ts.setEmitFlags(block, 1536);
73684             return block;
73685         }
73686         function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) {
73687             if (extendsClauseElement) {
73688                 statements.push(ts.setTextRange(factory.createExpressionStatement(emitHelpers().createExtendsHelper(factory.getInternalName(node))), extendsClauseElement));
73689             }
73690         }
73691         function addConstructor(statements, node, name, extendsClauseElement) {
73692             var savedConvertedLoopState = convertedLoopState;
73693             convertedLoopState = undefined;
73694             var ancestorFacts = enterSubtree(16278, 73);
73695             var constructor = ts.getFirstConstructorWithBody(node);
73696             var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined);
73697             var constructorFunction = factory.createFunctionDeclaration(undefined, undefined, undefined, name, undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper));
73698             ts.setTextRange(constructorFunction, constructor || node);
73699             if (extendsClauseElement) {
73700                 ts.setEmitFlags(constructorFunction, 8);
73701             }
73702             statements.push(constructorFunction);
73703             exitSubtree(ancestorFacts, 49152, 0);
73704             convertedLoopState = savedConvertedLoopState;
73705         }
73706         function transformConstructorParameters(constructor, hasSynthesizedSuper) {
73707             return ts.visitParameterList(constructor && !hasSynthesizedSuper ? constructor.parameters : undefined, visitor, context)
73708                 || [];
73709         }
73710         function createDefaultConstructorBody(node, isDerivedClass) {
73711             var statements = [];
73712             resumeLexicalEnvironment();
73713             factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
73714             if (isDerivedClass) {
73715                 statements.push(factory.createReturnStatement(createDefaultSuperCallOrThis()));
73716             }
73717             var statementsArray = factory.createNodeArray(statements);
73718             ts.setTextRange(statementsArray, node.members);
73719             var block = factory.createBlock(statementsArray, true);
73720             ts.setTextRange(block, node);
73721             ts.setEmitFlags(block, 1536);
73722             return block;
73723         }
73724         function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) {
73725             var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103;
73726             if (!constructor)
73727                 return createDefaultConstructorBody(node, isDerivedClass);
73728             var prologue = [];
73729             var statements = [];
73730             resumeLexicalEnvironment();
73731             var statementOffset = 0;
73732             if (!hasSynthesizedSuper)
73733                 statementOffset = factory.copyStandardPrologue(constructor.body.statements, prologue, false);
73734             addDefaultValueAssignmentsIfNeeded(statements, constructor);
73735             addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper);
73736             if (!hasSynthesizedSuper)
73737                 statementOffset = factory.copyCustomPrologue(constructor.body.statements, statements, statementOffset, visitor);
73738             var superCallExpression;
73739             if (hasSynthesizedSuper) {
73740                 superCallExpression = createDefaultSuperCallOrThis();
73741             }
73742             else if (isDerivedClass && statementOffset < constructor.body.statements.length) {
73743                 var firstStatement = constructor.body.statements[statementOffset];
73744                 if (ts.isExpressionStatement(firstStatement) && ts.isSuperCall(firstStatement.expression)) {
73745                     superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression);
73746                 }
73747             }
73748             if (superCallExpression) {
73749                 hierarchyFacts |= 8192;
73750                 statementOffset++;
73751             }
73752             ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset));
73753             factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
73754             insertCaptureNewTargetIfNeeded(prologue, constructor, false);
73755             if (isDerivedClass) {
73756                 if (superCallExpression && statementOffset === constructor.body.statements.length && !(constructor.body.transformFlags & 4096)) {
73757                     var superCall = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression);
73758                     var returnStatement = factory.createReturnStatement(superCallExpression);
73759                     ts.setCommentRange(returnStatement, ts.getCommentRange(superCall));
73760                     ts.setEmitFlags(superCall, 1536);
73761                     statements.push(returnStatement);
73762                 }
73763                 else {
73764                     insertCaptureThisForNode(statements, constructor, superCallExpression || createActualThis());
73765                     if (!isSufficientlyCoveredByReturnStatements(constructor.body)) {
73766                         statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 | 32)));
73767                     }
73768                 }
73769             }
73770             else {
73771                 insertCaptureThisForNodeIfNeeded(prologue, constructor);
73772             }
73773             var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(ts.concatenate(prologue, statements)), constructor.body.statements), true);
73774             ts.setTextRange(block, constructor.body);
73775             return block;
73776         }
73777         function isSufficientlyCoveredByReturnStatements(statement) {
73778             if (statement.kind === 242) {
73779                 return true;
73780             }
73781             else if (statement.kind === 234) {
73782                 var ifStatement = statement;
73783                 if (ifStatement.elseStatement) {
73784                     return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) &&
73785                         isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement);
73786                 }
73787             }
73788             else if (statement.kind === 230) {
73789                 var lastStatement = ts.lastOrUndefined(statement.statements);
73790                 if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) {
73791                     return true;
73792                 }
73793             }
73794             return false;
73795         }
73796         function createActualThis() {
73797             return ts.setEmitFlags(factory.createThis(), 4);
73798         }
73799         function createDefaultSuperCallOrThis() {
73800             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());
73801         }
73802         function visitParameter(node) {
73803             if (node.dotDotDotToken) {
73804                 return undefined;
73805             }
73806             else if (ts.isBindingPattern(node.name)) {
73807                 return ts.setOriginalNode(ts.setTextRange(factory.createParameterDeclaration(undefined, undefined, undefined, factory.getGeneratedNameForNode(node), undefined, undefined, undefined), node), node);
73808             }
73809             else if (node.initializer) {
73810                 return ts.setOriginalNode(ts.setTextRange(factory.createParameterDeclaration(undefined, undefined, undefined, node.name, undefined, undefined, undefined), node), node);
73811             }
73812             else {
73813                 return node;
73814             }
73815         }
73816         function hasDefaultValueOrBindingPattern(node) {
73817             return node.initializer !== undefined
73818                 || ts.isBindingPattern(node.name);
73819         }
73820         function addDefaultValueAssignmentsIfNeeded(statements, node) {
73821             if (!ts.some(node.parameters, hasDefaultValueOrBindingPattern)) {
73822                 return false;
73823             }
73824             var added = false;
73825             for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
73826                 var parameter = _a[_i];
73827                 var name = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken;
73828                 if (dotDotDotToken) {
73829                     continue;
73830                 }
73831                 if (ts.isBindingPattern(name)) {
73832                     added = insertDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) || added;
73833                 }
73834                 else if (initializer) {
73835                     insertDefaultValueAssignmentForInitializer(statements, parameter, name, initializer);
73836                     added = true;
73837                 }
73838             }
73839             return added;
73840         }
73841         function insertDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) {
73842             if (name.elements.length > 0) {
73843                 ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createVariableStatement(undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0, factory.getGeneratedNameForNode(parameter)))), 1048576));
73844                 return true;
73845             }
73846             else if (initializer) {
73847                 ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createExpressionStatement(factory.createAssignment(factory.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576));
73848                 return true;
73849             }
73850             return false;
73851         }
73852         function insertDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) {
73853             initializer = ts.visitNode(initializer, visitor, ts.isExpression);
73854             var statement = factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([
73855                 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))
73856             ]), parameter), 1 | 32 | 384 | 1536));
73857             ts.startOnNewLine(statement);
73858             ts.setTextRange(statement, parameter);
73859             ts.setEmitFlags(statement, 384 | 32 | 1048576 | 1536);
73860             ts.insertStatementAfterCustomPrologue(statements, statement);
73861         }
73862         function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) {
73863             return !!(node && node.dotDotDotToken && !inConstructorWithSynthesizedSuper);
73864         }
73865         function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) {
73866             var prologueStatements = [];
73867             var parameter = ts.lastOrUndefined(node.parameters);
73868             if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) {
73869                 return false;
73870             }
73871             var declarationName = parameter.name.kind === 78 ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(undefined);
73872             ts.setEmitFlags(declarationName, 48);
73873             var expressionName = parameter.name.kind === 78 ? factory.cloneNode(parameter.name) : declarationName;
73874             var restIndex = node.parameters.length - 1;
73875             var temp = factory.createLoopVariable();
73876             prologueStatements.push(ts.setEmitFlags(ts.setTextRange(factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
73877                 factory.createVariableDeclaration(declarationName, undefined, undefined, factory.createArrayLiteralExpression([]))
73878             ])), parameter), 1048576));
73879             var forStatement = factory.createForStatement(ts.setTextRange(factory.createVariableDeclarationList([
73880                 factory.createVariableDeclaration(temp, undefined, undefined, factory.createNumericLiteral(restIndex))
73881             ]), parameter), ts.setTextRange(factory.createLessThan(temp, factory.createPropertyAccessExpression(factory.createIdentifier("arguments"), "length")), parameter), ts.setTextRange(factory.createPostfixIncrement(temp), parameter), factory.createBlock([
73882                 ts.startOnNewLine(ts.setTextRange(factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(expressionName, restIndex === 0
73883                     ? temp
73884                     : factory.createSubtract(temp, factory.createNumericLiteral(restIndex))), factory.createElementAccessExpression(factory.createIdentifier("arguments"), temp))), parameter))
73885             ]));
73886             ts.setEmitFlags(forStatement, 1048576);
73887             ts.startOnNewLine(forStatement);
73888             prologueStatements.push(forStatement);
73889             if (parameter.name.kind !== 78) {
73890                 prologueStatements.push(ts.setEmitFlags(ts.setTextRange(factory.createVariableStatement(undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0, expressionName))), parameter), 1048576));
73891             }
73892             ts.insertStatementsAfterCustomPrologue(statements, prologueStatements);
73893             return true;
73894         }
73895         function insertCaptureThisForNodeIfNeeded(statements, node) {
73896             if (hierarchyFacts & 32768 && node.kind !== 209) {
73897                 insertCaptureThisForNode(statements, node, factory.createThis());
73898                 return true;
73899             }
73900             return false;
73901         }
73902         function insertCaptureThisForNode(statements, node, initializer) {
73903             enableSubstitutionsForCapturedThis();
73904             var captureThisStatement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
73905                 factory.createVariableDeclaration(factory.createUniqueName("_this", 16 | 32), undefined, undefined, initializer)
73906             ]));
73907             ts.setEmitFlags(captureThisStatement, 1536 | 1048576);
73908             ts.setSourceMapRange(captureThisStatement, node);
73909             ts.insertStatementAfterCustomPrologue(statements, captureThisStatement);
73910         }
73911         function insertCaptureNewTargetIfNeeded(statements, node, copyOnWrite) {
73912             if (hierarchyFacts & 16384) {
73913                 var newTarget = void 0;
73914                 switch (node.kind) {
73915                     case 209:
73916                         return statements;
73917                     case 165:
73918                     case 167:
73919                     case 168:
73920                         newTarget = factory.createVoidZero();
73921                         break;
73922                     case 166:
73923                         newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4), "constructor");
73924                         break;
73925                     case 251:
73926                     case 208:
73927                         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());
73928                         break;
73929                     default:
73930                         return ts.Debug.failBadSyntaxKind(node);
73931                 }
73932                 var captureNewTargetStatement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
73933                     factory.createVariableDeclaration(factory.createUniqueName("_newTarget", 16 | 32), undefined, undefined, newTarget)
73934                 ]));
73935                 ts.setEmitFlags(captureNewTargetStatement, 1536 | 1048576);
73936                 if (copyOnWrite) {
73937                     statements = statements.slice();
73938                 }
73939                 ts.insertStatementAfterCustomPrologue(statements, captureNewTargetStatement);
73940             }
73941             return statements;
73942         }
73943         function addClassMembers(statements, node) {
73944             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
73945                 var member = _a[_i];
73946                 switch (member.kind) {
73947                     case 229:
73948                         statements.push(transformSemicolonClassElementToStatement(member));
73949                         break;
73950                     case 165:
73951                         statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node));
73952                         break;
73953                     case 167:
73954                     case 168:
73955                         var accessors = ts.getAllAccessorDeclarations(node.members, member);
73956                         if (member === accessors.firstAccessor) {
73957                             statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node));
73958                         }
73959                         break;
73960                     case 166:
73961                         break;
73962                     default:
73963                         ts.Debug.failBadSyntaxKind(member, currentSourceFile && currentSourceFile.fileName);
73964                         break;
73965                 }
73966             }
73967         }
73968         function transformSemicolonClassElementToStatement(member) {
73969             return ts.setTextRange(factory.createEmptyStatement(), member);
73970         }
73971         function transformClassMethodDeclarationToStatement(receiver, member, container) {
73972             var commentRange = ts.getCommentRange(member);
73973             var sourceMapRange = ts.getSourceMapRange(member);
73974             var memberFunction = transformFunctionLikeToExpression(member, member, undefined, container);
73975             var propertyName = ts.visitNode(member.name, visitor, ts.isPropertyName);
73976             var e;
73977             if (!ts.isPrivateIdentifier(propertyName) && context.getCompilerOptions().useDefineForClassFields) {
73978                 var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression
73979                     : ts.isIdentifier(propertyName) ? factory.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText))
73980                         : propertyName;
73981                 e = factory.createObjectDefinePropertyCall(receiver, name, factory.createPropertyDescriptor({ value: memberFunction, enumerable: false, writable: true, configurable: true }));
73982             }
73983             else {
73984                 var memberName = ts.createMemberAccessForPropertyName(factory, receiver, propertyName, member.name);
73985                 e = factory.createAssignment(memberName, memberFunction);
73986             }
73987             ts.setEmitFlags(memberFunction, 1536);
73988             ts.setSourceMapRange(memberFunction, sourceMapRange);
73989             var statement = ts.setTextRange(factory.createExpressionStatement(e), member);
73990             ts.setOriginalNode(statement, member);
73991             ts.setCommentRange(statement, commentRange);
73992             ts.setEmitFlags(statement, 48);
73993             return statement;
73994         }
73995         function transformAccessorsToStatement(receiver, accessors, container) {
73996             var statement = factory.createExpressionStatement(transformAccessorsToExpression(receiver, accessors, container, false));
73997             ts.setEmitFlags(statement, 1536);
73998             ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor));
73999             return statement;
74000         }
74001         function transformAccessorsToExpression(receiver, _a, container, startsOnNewLine) {
74002             var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor;
74003             var target = ts.setParent(ts.setTextRange(factory.cloneNode(receiver), receiver), receiver.parent);
74004             ts.setEmitFlags(target, 1536 | 32);
74005             ts.setSourceMapRange(target, firstAccessor.name);
74006             var visitedAccessorName = ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName);
74007             if (ts.isPrivateIdentifier(visitedAccessorName)) {
74008                 return ts.Debug.failBadSyntaxKind(visitedAccessorName, "Encountered unhandled private identifier while transforming ES2015.");
74009             }
74010             var propertyName = ts.createExpressionForPropertyName(factory, visitedAccessorName);
74011             ts.setEmitFlags(propertyName, 1536 | 16);
74012             ts.setSourceMapRange(propertyName, firstAccessor.name);
74013             var properties = [];
74014             if (getAccessor) {
74015                 var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined, container);
74016                 ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor));
74017                 ts.setEmitFlags(getterFunction, 512);
74018                 var getter = factory.createPropertyAssignment("get", getterFunction);
74019                 ts.setCommentRange(getter, ts.getCommentRange(getAccessor));
74020                 properties.push(getter);
74021             }
74022             if (setAccessor) {
74023                 var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined, container);
74024                 ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor));
74025                 ts.setEmitFlags(setterFunction, 512);
74026                 var setter = factory.createPropertyAssignment("set", setterFunction);
74027                 ts.setCommentRange(setter, ts.getCommentRange(setAccessor));
74028                 properties.push(setter);
74029             }
74030             properties.push(factory.createPropertyAssignment("enumerable", getAccessor || setAccessor ? factory.createFalse() : factory.createTrue()), factory.createPropertyAssignment("configurable", factory.createTrue()));
74031             var call = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), undefined, [
74032                 target,
74033                 propertyName,
74034                 factory.createObjectLiteralExpression(properties, true)
74035             ]);
74036             if (startsOnNewLine) {
74037                 ts.startOnNewLine(call);
74038             }
74039             return call;
74040         }
74041         function visitArrowFunction(node) {
74042             if (node.transformFlags & 4096) {
74043                 hierarchyFacts |= 32768;
74044             }
74045             var savedConvertedLoopState = convertedLoopState;
74046             convertedLoopState = undefined;
74047             var ancestorFacts = enterSubtree(15232, 66);
74048             var func = factory.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node));
74049             ts.setTextRange(func, node);
74050             ts.setOriginalNode(func, node);
74051             ts.setEmitFlags(func, 8);
74052             if (hierarchyFacts & 32768) {
74053                 enableSubstitutionsForCapturedThis();
74054             }
74055             exitSubtree(ancestorFacts, 0, 0);
74056             convertedLoopState = savedConvertedLoopState;
74057             return func;
74058         }
74059         function visitFunctionExpression(node) {
74060             var ancestorFacts = ts.getEmitFlags(node) & 262144
74061                 ? enterSubtree(16278, 69)
74062                 : enterSubtree(16286, 65);
74063             var savedConvertedLoopState = convertedLoopState;
74064             convertedLoopState = undefined;
74065             var parameters = ts.visitParameterList(node.parameters, visitor, context);
74066             var body = transformFunctionBody(node);
74067             var name = hierarchyFacts & 16384
74068                 ? factory.getLocalName(node)
74069                 : node.name;
74070             exitSubtree(ancestorFacts, 49152, 0);
74071             convertedLoopState = savedConvertedLoopState;
74072             return factory.updateFunctionExpression(node, undefined, node.asteriskToken, name, undefined, parameters, undefined, body);
74073         }
74074         function visitFunctionDeclaration(node) {
74075             var savedConvertedLoopState = convertedLoopState;
74076             convertedLoopState = undefined;
74077             var ancestorFacts = enterSubtree(16286, 65);
74078             var parameters = ts.visitParameterList(node.parameters, visitor, context);
74079             var body = transformFunctionBody(node);
74080             var name = hierarchyFacts & 16384
74081                 ? factory.getLocalName(node)
74082                 : node.name;
74083             exitSubtree(ancestorFacts, 49152, 0);
74084             convertedLoopState = savedConvertedLoopState;
74085             return factory.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name, undefined, parameters, undefined, body);
74086         }
74087         function transformFunctionLikeToExpression(node, location, name, container) {
74088             var savedConvertedLoopState = convertedLoopState;
74089             convertedLoopState = undefined;
74090             var ancestorFacts = container && ts.isClassLike(container) && !ts.hasSyntacticModifier(node, 32)
74091                 ? enterSubtree(16286, 65 | 8)
74092                 : enterSubtree(16286, 65);
74093             var parameters = ts.visitParameterList(node.parameters, visitor, context);
74094             var body = transformFunctionBody(node);
74095             if (hierarchyFacts & 16384 && !name && (node.kind === 251 || node.kind === 208)) {
74096                 name = factory.getGeneratedNameForNode(node);
74097             }
74098             exitSubtree(ancestorFacts, 49152, 0);
74099             convertedLoopState = savedConvertedLoopState;
74100             return ts.setOriginalNode(ts.setTextRange(factory.createFunctionExpression(undefined, node.asteriskToken, name, undefined, parameters, undefined, body), location), node);
74101         }
74102         function transformFunctionBody(node) {
74103             var multiLine = false;
74104             var singleLine = false;
74105             var statementsLocation;
74106             var closeBraceLocation;
74107             var prologue = [];
74108             var statements = [];
74109             var body = node.body;
74110             var statementOffset;
74111             resumeLexicalEnvironment();
74112             if (ts.isBlock(body)) {
74113                 statementOffset = factory.copyStandardPrologue(body.statements, prologue, false);
74114                 statementOffset = factory.copyCustomPrologue(body.statements, statements, statementOffset, visitor, ts.isHoistedFunction);
74115                 statementOffset = factory.copyCustomPrologue(body.statements, statements, statementOffset, visitor, ts.isHoistedVariableStatement);
74116             }
74117             multiLine = addDefaultValueAssignmentsIfNeeded(statements, node) || multiLine;
74118             multiLine = addRestParameterIfNeeded(statements, node, false) || multiLine;
74119             if (ts.isBlock(body)) {
74120                 statementOffset = factory.copyCustomPrologue(body.statements, statements, statementOffset, visitor);
74121                 statementsLocation = body.statements;
74122                 ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset));
74123                 if (!multiLine && body.multiLine) {
74124                     multiLine = true;
74125                 }
74126             }
74127             else {
74128                 ts.Debug.assert(node.kind === 209);
74129                 statementsLocation = ts.moveRangeEnd(body, -1);
74130                 var equalsGreaterThanToken = node.equalsGreaterThanToken;
74131                 if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) {
74132                     if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) {
74133                         singleLine = true;
74134                     }
74135                     else {
74136                         multiLine = true;
74137                     }
74138                 }
74139                 var expression = ts.visitNode(body, visitor, ts.isExpression);
74140                 var returnStatement = factory.createReturnStatement(expression);
74141                 ts.setTextRange(returnStatement, body);
74142                 ts.moveSyntheticComments(returnStatement, body);
74143                 ts.setEmitFlags(returnStatement, 384 | 32 | 1024);
74144                 statements.push(returnStatement);
74145                 closeBraceLocation = body;
74146             }
74147             factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
74148             insertCaptureNewTargetIfNeeded(prologue, node, false);
74149             insertCaptureThisForNodeIfNeeded(prologue, node);
74150             if (ts.some(prologue)) {
74151                 multiLine = true;
74152             }
74153             statements.unshift.apply(statements, prologue);
74154             if (ts.isBlock(body) && ts.arrayIsEqualTo(statements, body.statements)) {
74155                 return body;
74156             }
74157             var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), multiLine);
74158             ts.setTextRange(block, node.body);
74159             if (!multiLine && singleLine) {
74160                 ts.setEmitFlags(block, 1);
74161             }
74162             if (closeBraceLocation) {
74163                 ts.setTokenSourceMapRange(block, 19, closeBraceLocation);
74164             }
74165             ts.setOriginalNode(block, node.body);
74166             return block;
74167         }
74168         function visitBlock(node, isFunctionBody) {
74169             if (isFunctionBody) {
74170                 return ts.visitEachChild(node, visitor, context);
74171             }
74172             var ancestorFacts = hierarchyFacts & 256
74173                 ? enterSubtree(7104, 512)
74174                 : enterSubtree(6976, 128);
74175             var updated = ts.visitEachChild(node, visitor, context);
74176             exitSubtree(ancestorFacts, 0, 0);
74177             return updated;
74178         }
74179         function visitExpressionStatement(node) {
74180             return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
74181         }
74182         function visitParenthesizedExpression(node, expressionResultIsUnused) {
74183             return ts.visitEachChild(node, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, context);
74184         }
74185         function visitBinaryExpression(node, expressionResultIsUnused) {
74186             if (ts.isDestructuringAssignment(node)) {
74187                 return ts.flattenDestructuringAssignment(node, visitor, context, 0, !expressionResultIsUnused);
74188             }
74189             if (node.operatorToken.kind === 27) {
74190                 return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression));
74191             }
74192             return ts.visitEachChild(node, visitor, context);
74193         }
74194         function visitCommaListExpression(node, expressionResultIsUnused) {
74195             if (expressionResultIsUnused) {
74196                 return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
74197             }
74198             var result;
74199             for (var i = 0; i < node.elements.length; i++) {
74200                 var element = node.elements[i];
74201                 var visited = ts.visitNode(element, i < node.elements.length - 1 ? visitorWithUnusedExpressionResult : visitor, ts.isExpression);
74202                 if (result || visited !== element) {
74203                     result || (result = node.elements.slice(0, i));
74204                     result.push(visited);
74205                 }
74206             }
74207             var elements = result ? ts.setTextRange(factory.createNodeArray(result), node.elements) : node.elements;
74208             return factory.updateCommaListExpression(node, elements);
74209         }
74210         function isVariableStatementOfTypeScriptClassWrapper(node) {
74211             return node.declarationList.declarations.length === 1
74212                 && !!node.declarationList.declarations[0].initializer
74213                 && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432);
74214         }
74215         function visitVariableStatement(node) {
74216             var ancestorFacts = enterSubtree(0, ts.hasSyntacticModifier(node, 1) ? 32 : 0);
74217             var updated;
74218             if (convertedLoopState && (node.declarationList.flags & 3) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) {
74219                 var assignments = void 0;
74220                 for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
74221                     var decl = _a[_i];
74222                     hoistVariableDeclarationDeclaredInConvertedLoop(convertedLoopState, decl);
74223                     if (decl.initializer) {
74224                         var assignment = void 0;
74225                         if (ts.isBindingPattern(decl.name)) {
74226                             assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0);
74227                         }
74228                         else {
74229                             assignment = factory.createBinaryExpression(decl.name, 62, ts.visitNode(decl.initializer, visitor, ts.isExpression));
74230                             ts.setTextRange(assignment, decl);
74231                         }
74232                         assignments = ts.append(assignments, assignment);
74233                     }
74234                 }
74235                 if (assignments) {
74236                     updated = ts.setTextRange(factory.createExpressionStatement(factory.inlineExpressions(assignments)), node);
74237                 }
74238                 else {
74239                     updated = undefined;
74240                 }
74241             }
74242             else {
74243                 updated = ts.visitEachChild(node, visitor, context);
74244             }
74245             exitSubtree(ancestorFacts, 0, 0);
74246             return updated;
74247         }
74248         function visitVariableDeclarationList(node) {
74249             if (node.flags & 3 || node.transformFlags & 131072) {
74250                 if (node.flags & 3) {
74251                     enableSubstitutionsForBlockScopedBindings();
74252                 }
74253                 var declarations = ts.flatMap(node.declarations, node.flags & 1
74254                     ? visitVariableDeclarationInLetDeclarationList
74255                     : visitVariableDeclaration);
74256                 var declarationList = factory.createVariableDeclarationList(declarations);
74257                 ts.setOriginalNode(declarationList, node);
74258                 ts.setTextRange(declarationList, node);
74259                 ts.setCommentRange(declarationList, node);
74260                 if (node.transformFlags & 131072
74261                     && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) {
74262                     ts.setSourceMapRange(declarationList, getRangeUnion(declarations));
74263                 }
74264                 return declarationList;
74265             }
74266             return ts.visitEachChild(node, visitor, context);
74267         }
74268         function getRangeUnion(declarations) {
74269             var pos = -1, end = -1;
74270             for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) {
74271                 var node = declarations_10[_i];
74272                 pos = pos === -1 ? node.pos : node.pos === -1 ? pos : Math.min(pos, node.pos);
74273                 end = Math.max(end, node.end);
74274             }
74275             return ts.createRange(pos, end);
74276         }
74277         function shouldEmitExplicitInitializerForLetDeclaration(node) {
74278             var flags = resolver.getNodeCheckFlags(node);
74279             var isCapturedInFunction = flags & 262144;
74280             var isDeclaredInLoop = flags & 524288;
74281             var emittedAsTopLevel = (hierarchyFacts & 64) !== 0
74282                 || (isCapturedInFunction
74283                     && isDeclaredInLoop
74284                     && (hierarchyFacts & 512) !== 0);
74285             var emitExplicitInitializer = !emittedAsTopLevel
74286                 && (hierarchyFacts & 4096) === 0
74287                 && (!resolver.isDeclarationWithCollidingName(node)
74288                     || (isDeclaredInLoop
74289                         && !isCapturedInFunction
74290                         && (hierarchyFacts & (2048 | 4096)) === 0));
74291             return emitExplicitInitializer;
74292         }
74293         function visitVariableDeclarationInLetDeclarationList(node) {
74294             var name = node.name;
74295             if (ts.isBindingPattern(name)) {
74296                 return visitVariableDeclaration(node);
74297             }
74298             if (!node.initializer && shouldEmitExplicitInitializerForLetDeclaration(node)) {
74299                 return factory.updateVariableDeclaration(node, node.name, undefined, undefined, factory.createVoidZero());
74300             }
74301             return ts.visitEachChild(node, visitor, context);
74302         }
74303         function visitVariableDeclaration(node) {
74304             var ancestorFacts = enterSubtree(32, 0);
74305             var updated;
74306             if (ts.isBindingPattern(node.name)) {
74307                 updated = ts.flattenDestructuringBinding(node, visitor, context, 0, undefined, (ancestorFacts & 32) !== 0);
74308             }
74309             else {
74310                 updated = ts.visitEachChild(node, visitor, context);
74311             }
74312             exitSubtree(ancestorFacts, 0, 0);
74313             return updated;
74314         }
74315         function recordLabel(node) {
74316             convertedLoopState.labels.set(ts.idText(node.label), true);
74317         }
74318         function resetLabel(node) {
74319             convertedLoopState.labels.set(ts.idText(node.label), false);
74320         }
74321         function visitLabeledStatement(node) {
74322             if (convertedLoopState && !convertedLoopState.labels) {
74323                 convertedLoopState.labels = new ts.Map();
74324             }
74325             var statement = ts.unwrapInnermostStatementOfLabel(node, convertedLoopState && recordLabel);
74326             return ts.isIterationStatement(statement, false)
74327                 ? visitIterationStatement(statement, node)
74328                 : factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node, convertedLoopState && resetLabel);
74329         }
74330         function visitIterationStatement(node, outermostLabeledStatement) {
74331             switch (node.kind) {
74332                 case 235:
74333                 case 236:
74334                     return visitDoOrWhileStatement(node, outermostLabeledStatement);
74335                 case 237:
74336                     return visitForStatement(node, outermostLabeledStatement);
74337                 case 238:
74338                     return visitForInStatement(node, outermostLabeledStatement);
74339                 case 239:
74340                     return visitForOfStatement(node, outermostLabeledStatement);
74341             }
74342         }
74343         function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) {
74344             var ancestorFacts = enterSubtree(excludeFacts, includeFacts);
74345             var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert);
74346             exitSubtree(ancestorFacts, 0, 0);
74347             return updated;
74348         }
74349         function visitDoOrWhileStatement(node, outermostLabeledStatement) {
74350             return visitIterationStatementWithFacts(0, 1280, node, outermostLabeledStatement);
74351         }
74352         function visitForStatement(node, outermostLabeledStatement) {
74353             return visitIterationStatementWithFacts(5056, 3328, node, outermostLabeledStatement);
74354         }
74355         function visitEachChildOfForStatement(node) {
74356             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));
74357         }
74358         function visitForInStatement(node, outermostLabeledStatement) {
74359             return visitIterationStatementWithFacts(3008, 5376, node, outermostLabeledStatement);
74360         }
74361         function visitForOfStatement(node, outermostLabeledStatement) {
74362             return visitIterationStatementWithFacts(3008, 5376, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray);
74363         }
74364         function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) {
74365             var statements = [];
74366             var initializer = node.initializer;
74367             if (ts.isVariableDeclarationList(initializer)) {
74368                 if (node.initializer.flags & 3) {
74369                     enableSubstitutionsForBlockScopedBindings();
74370                 }
74371                 var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations);
74372                 if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) {
74373                     var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0, boundValue);
74374                     var declarationList = ts.setTextRange(factory.createVariableDeclarationList(declarations), node.initializer);
74375                     ts.setOriginalNode(declarationList, node.initializer);
74376                     ts.setSourceMapRange(declarationList, ts.createRange(declarations[0].pos, ts.last(declarations).end));
74377                     statements.push(factory.createVariableStatement(undefined, declarationList));
74378                 }
74379                 else {
74380                     statements.push(ts.setTextRange(factory.createVariableStatement(undefined, ts.setOriginalNode(ts.setTextRange(factory.createVariableDeclarationList([
74381                         factory.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : factory.createTempVariable(undefined), undefined, undefined, boundValue)
74382                     ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1)));
74383                 }
74384             }
74385             else {
74386                 var assignment = factory.createAssignment(initializer, boundValue);
74387                 if (ts.isDestructuringAssignment(assignment)) {
74388                     statements.push(factory.createExpressionStatement(visitBinaryExpression(assignment, true)));
74389                 }
74390                 else {
74391                     ts.setTextRangeEnd(assignment, initializer.end);
74392                     statements.push(ts.setTextRange(factory.createExpressionStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1)));
74393                 }
74394             }
74395             if (convertedLoopBodyStatements) {
74396                 return createSyntheticBlockForConvertedStatements(ts.addRange(statements, convertedLoopBodyStatements));
74397             }
74398             else {
74399                 var statement = ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock);
74400                 if (ts.isBlock(statement)) {
74401                     return factory.updateBlock(statement, ts.setTextRange(factory.createNodeArray(ts.concatenate(statements, statement.statements)), statement.statements));
74402                 }
74403                 else {
74404                     statements.push(statement);
74405                     return createSyntheticBlockForConvertedStatements(statements);
74406                 }
74407             }
74408         }
74409         function createSyntheticBlockForConvertedStatements(statements) {
74410             return ts.setEmitFlags(factory.createBlock(factory.createNodeArray(statements), true), 48 | 384);
74411         }
74412         function convertForOfStatementForArray(node, outermostLabeledStatement, convertedLoopBodyStatements) {
74413             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
74414             var counter = factory.createLoopVariable();
74415             var rhsReference = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(expression) : factory.createTempVariable(undefined);
74416             ts.setEmitFlags(expression, 48 | ts.getEmitFlags(expression));
74417             var forStatement = ts.setTextRange(factory.createForStatement(ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([
74418                 ts.setTextRange(factory.createVariableDeclaration(counter, undefined, undefined, factory.createNumericLiteral(0)), ts.moveRangePos(node.expression, -1)),
74419                 ts.setTextRange(factory.createVariableDeclaration(rhsReference, undefined, undefined, expression), node.expression)
74420             ]), 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);
74421             ts.setEmitFlags(forStatement, 256);
74422             ts.setTextRange(forStatement, node);
74423             return factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel);
74424         }
74425         function convertForOfStatementForIterable(node, outermostLabeledStatement, convertedLoopBodyStatements, ancestorFacts) {
74426             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
74427             var iterator = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(expression) : factory.createTempVariable(undefined);
74428             var result = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(iterator) : factory.createTempVariable(undefined);
74429             var errorRecord = factory.createUniqueName("e");
74430             var catchVariable = factory.getGeneratedNameForNode(errorRecord);
74431             var returnMethod = factory.createTempVariable(undefined);
74432             var values = ts.setTextRange(emitHelpers().createValuesHelper(expression), node.expression);
74433             var next = factory.createCallExpression(factory.createPropertyAccessExpression(iterator, "next"), undefined, []);
74434             hoistVariableDeclaration(errorRecord);
74435             hoistVariableDeclaration(returnMethod);
74436             var initializer = ancestorFacts & 1024
74437                 ? factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), values])
74438                 : values;
74439             var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement(ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([
74440                 ts.setTextRange(factory.createVariableDeclaration(iterator, undefined, undefined, initializer), node.expression),
74441                 factory.createVariableDeclaration(result, undefined, undefined, next)
74442             ]), node.expression), 2097152), factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done")), factory.createAssignment(result, next), convertForOfStatementHead(node, factory.createPropertyAccessExpression(result, "value"), convertedLoopBodyStatements)), node), 256);
74443             return factory.createTryStatement(factory.createBlock([
74444                 factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel)
74445             ]), factory.createCatchClause(factory.createVariableDeclaration(catchVariable), ts.setEmitFlags(factory.createBlock([
74446                 factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([
74447                     factory.createPropertyAssignment("error", catchVariable)
74448                 ])))
74449             ]), 1)), factory.createBlock([
74450                 factory.createTryStatement(factory.createBlock([
74451                     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),
74452                 ]), undefined, ts.setEmitFlags(factory.createBlock([
74453                     ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1)
74454                 ]), 1))
74455             ]));
74456         }
74457         function visitObjectLiteralExpression(node) {
74458             var properties = node.properties;
74459             var numInitialProperties = -1, hasComputed = false;
74460             for (var i = 0; i < properties.length; i++) {
74461                 var property = properties[i];
74462                 if ((property.transformFlags & 262144 &&
74463                     hierarchyFacts & 4)
74464                     || (hasComputed = ts.Debug.checkDefined(property.name).kind === 158)) {
74465                     numInitialProperties = i;
74466                     break;
74467                 }
74468             }
74469             if (numInitialProperties < 0) {
74470                 return ts.visitEachChild(node, visitor, context);
74471             }
74472             var temp = factory.createTempVariable(hoistVariableDeclaration);
74473             var expressions = [];
74474             var assignment = factory.createAssignment(temp, ts.setEmitFlags(factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), hasComputed ? 65536 : 0));
74475             if (node.multiLine) {
74476                 ts.startOnNewLine(assignment);
74477             }
74478             expressions.push(assignment);
74479             addObjectLiteralMembers(expressions, node, temp, numInitialProperties);
74480             expressions.push(node.multiLine ? ts.startOnNewLine(ts.setParent(ts.setTextRange(factory.cloneNode(temp), temp), temp.parent)) : temp);
74481             return factory.inlineExpressions(expressions);
74482         }
74483         function shouldConvertPartOfIterationStatement(node) {
74484             return (resolver.getNodeCheckFlags(node) & 131072) !== 0;
74485         }
74486         function shouldConvertInitializerOfForStatement(node) {
74487             return ts.isForStatement(node) && !!node.initializer && shouldConvertPartOfIterationStatement(node.initializer);
74488         }
74489         function shouldConvertConditionOfForStatement(node) {
74490             return ts.isForStatement(node) && !!node.condition && shouldConvertPartOfIterationStatement(node.condition);
74491         }
74492         function shouldConvertIncrementorOfForStatement(node) {
74493             return ts.isForStatement(node) && !!node.incrementor && shouldConvertPartOfIterationStatement(node.incrementor);
74494         }
74495         function shouldConvertIterationStatement(node) {
74496             return shouldConvertBodyOfIterationStatement(node)
74497                 || shouldConvertInitializerOfForStatement(node);
74498         }
74499         function shouldConvertBodyOfIterationStatement(node) {
74500             return (resolver.getNodeCheckFlags(node) & 65536) !== 0;
74501         }
74502         function hoistVariableDeclarationDeclaredInConvertedLoop(state, node) {
74503             if (!state.hoistedLocalVariables) {
74504                 state.hoistedLocalVariables = [];
74505             }
74506             visit(node.name);
74507             function visit(node) {
74508                 if (node.kind === 78) {
74509                     state.hoistedLocalVariables.push(node);
74510                 }
74511                 else {
74512                     for (var _i = 0, _a = node.elements; _i < _a.length; _i++) {
74513                         var element = _a[_i];
74514                         if (!ts.isOmittedExpression(element)) {
74515                             visit(element.name);
74516                         }
74517                     }
74518                 }
74519             }
74520         }
74521         function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert) {
74522             if (!shouldConvertIterationStatement(node)) {
74523                 var saveAllowedNonLabeledJumps = void 0;
74524                 if (convertedLoopState) {
74525                     saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps;
74526                     convertedLoopState.allowedNonLabeledJumps = 2 | 4;
74527                 }
74528                 var result = convert
74529                     ? convert(node, outermostLabeledStatement, undefined, ancestorFacts)
74530                     : factory.restoreEnclosingLabel(ts.isForStatement(node) ? visitEachChildOfForStatement(node) : ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel);
74531                 if (convertedLoopState) {
74532                     convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps;
74533                 }
74534                 return result;
74535             }
74536             var currentState = createConvertedLoopState(node);
74537             var statements = [];
74538             var outerConvertedLoopState = convertedLoopState;
74539             convertedLoopState = currentState;
74540             var initializerFunction = shouldConvertInitializerOfForStatement(node) ? createFunctionForInitializerOfForStatement(node, currentState) : undefined;
74541             var bodyFunction = shouldConvertBodyOfIterationStatement(node) ? createFunctionForBodyOfIterationStatement(node, currentState, outerConvertedLoopState) : undefined;
74542             convertedLoopState = outerConvertedLoopState;
74543             if (initializerFunction)
74544                 statements.push(initializerFunction.functionDeclaration);
74545             if (bodyFunction)
74546                 statements.push(bodyFunction.functionDeclaration);
74547             addExtraDeclarationsForConvertedLoop(statements, currentState, outerConvertedLoopState);
74548             if (initializerFunction) {
74549                 statements.push(generateCallToConvertedLoopInitializer(initializerFunction.functionName, initializerFunction.containsYield));
74550             }
74551             var loop;
74552             if (bodyFunction) {
74553                 if (convert) {
74554                     loop = convert(node, outermostLabeledStatement, bodyFunction.part, ancestorFacts);
74555                 }
74556                 else {
74557                     var clone_3 = convertIterationStatementCore(node, initializerFunction, factory.createBlock(bodyFunction.part, true));
74558                     loop = factory.restoreEnclosingLabel(clone_3, outermostLabeledStatement, convertedLoopState && resetLabel);
74559                 }
74560             }
74561             else {
74562                 var clone_4 = convertIterationStatementCore(node, initializerFunction, ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock));
74563                 loop = factory.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel);
74564             }
74565             statements.push(loop);
74566             return statements;
74567         }
74568         function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) {
74569             switch (node.kind) {
74570                 case 237: return convertForStatement(node, initializerFunction, convertedLoopBody);
74571                 case 238: return convertForInStatement(node, convertedLoopBody);
74572                 case 239: return convertForOfStatement(node, convertedLoopBody);
74573                 case 235: return convertDoStatement(node, convertedLoopBody);
74574                 case 236: return convertWhileStatement(node, convertedLoopBody);
74575                 default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected");
74576             }
74577         }
74578         function convertForStatement(node, initializerFunction, convertedLoopBody) {
74579             var shouldConvertCondition = node.condition && shouldConvertPartOfIterationStatement(node.condition);
74580             var shouldConvertIncrementor = shouldConvertCondition || node.incrementor && shouldConvertPartOfIterationStatement(node.incrementor);
74581             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);
74582         }
74583         function convertForOfStatement(node, convertedLoopBody) {
74584             return factory.updateForOfStatement(node, undefined, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), convertedLoopBody);
74585         }
74586         function convertForInStatement(node, convertedLoopBody) {
74587             return factory.updateForInStatement(node, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), convertedLoopBody);
74588         }
74589         function convertDoStatement(node, convertedLoopBody) {
74590             return factory.updateDoStatement(node, convertedLoopBody, ts.visitNode(node.expression, visitor, ts.isExpression));
74591         }
74592         function convertWhileStatement(node, convertedLoopBody) {
74593             return factory.updateWhileStatement(node, ts.visitNode(node.expression, visitor, ts.isExpression), convertedLoopBody);
74594         }
74595         function createConvertedLoopState(node) {
74596             var loopInitializer;
74597             switch (node.kind) {
74598                 case 237:
74599                 case 238:
74600                 case 239:
74601                     var initializer = node.initializer;
74602                     if (initializer && initializer.kind === 250) {
74603                         loopInitializer = initializer;
74604                     }
74605                     break;
74606             }
74607             var loopParameters = [];
74608             var loopOutParameters = [];
74609             if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3)) {
74610                 var hasCapturedBindingsInForInitializer = shouldConvertInitializerOfForStatement(node);
74611                 for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) {
74612                     var decl = _a[_i];
74613                     processLoopVariableDeclaration(node, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
74614                 }
74615             }
74616             var currentState = { loopParameters: loopParameters, loopOutParameters: loopOutParameters };
74617             if (convertedLoopState) {
74618                 if (convertedLoopState.argumentsName) {
74619                     currentState.argumentsName = convertedLoopState.argumentsName;
74620                 }
74621                 if (convertedLoopState.thisName) {
74622                     currentState.thisName = convertedLoopState.thisName;
74623                 }
74624                 if (convertedLoopState.hoistedLocalVariables) {
74625                     currentState.hoistedLocalVariables = convertedLoopState.hoistedLocalVariables;
74626                 }
74627             }
74628             return currentState;
74629         }
74630         function addExtraDeclarationsForConvertedLoop(statements, state, outerState) {
74631             var extraVariableDeclarations;
74632             if (state.argumentsName) {
74633                 if (outerState) {
74634                     outerState.argumentsName = state.argumentsName;
74635                 }
74636                 else {
74637                     (extraVariableDeclarations || (extraVariableDeclarations = [])).push(factory.createVariableDeclaration(state.argumentsName, undefined, undefined, factory.createIdentifier("arguments")));
74638                 }
74639             }
74640             if (state.thisName) {
74641                 if (outerState) {
74642                     outerState.thisName = state.thisName;
74643                 }
74644                 else {
74645                     (extraVariableDeclarations || (extraVariableDeclarations = [])).push(factory.createVariableDeclaration(state.thisName, undefined, undefined, factory.createIdentifier("this")));
74646                 }
74647             }
74648             if (state.hoistedLocalVariables) {
74649                 if (outerState) {
74650                     outerState.hoistedLocalVariables = state.hoistedLocalVariables;
74651                 }
74652                 else {
74653                     if (!extraVariableDeclarations) {
74654                         extraVariableDeclarations = [];
74655                     }
74656                     for (var _i = 0, _a = state.hoistedLocalVariables; _i < _a.length; _i++) {
74657                         var identifier = _a[_i];
74658                         extraVariableDeclarations.push(factory.createVariableDeclaration(identifier));
74659                     }
74660                 }
74661             }
74662             if (state.loopOutParameters.length) {
74663                 if (!extraVariableDeclarations) {
74664                     extraVariableDeclarations = [];
74665                 }
74666                 for (var _b = 0, _c = state.loopOutParameters; _b < _c.length; _b++) {
74667                     var outParam = _c[_b];
74668                     extraVariableDeclarations.push(factory.createVariableDeclaration(outParam.outParamName));
74669                 }
74670             }
74671             if (state.conditionVariable) {
74672                 if (!extraVariableDeclarations) {
74673                     extraVariableDeclarations = [];
74674                 }
74675                 extraVariableDeclarations.push(factory.createVariableDeclaration(state.conditionVariable, undefined, undefined, factory.createFalse()));
74676             }
74677             if (extraVariableDeclarations) {
74678                 statements.push(factory.createVariableStatement(undefined, factory.createVariableDeclarationList(extraVariableDeclarations)));
74679             }
74680         }
74681         function createOutVariable(p) {
74682             return factory.createVariableDeclaration(p.originalName, undefined, undefined, p.outParamName);
74683         }
74684         function createFunctionForInitializerOfForStatement(node, currentState) {
74685             var functionName = factory.createUniqueName("_loop_init");
74686             var containsYield = (node.initializer.transformFlags & 262144) !== 0;
74687             var emitFlags = 0;
74688             if (currentState.containsLexicalThis)
74689                 emitFlags |= 8;
74690             if (containsYield && hierarchyFacts & 4)
74691                 emitFlags |= 262144;
74692             var statements = [];
74693             statements.push(factory.createVariableStatement(undefined, node.initializer));
74694             copyOutParameters(currentState.loopOutParameters, 2, 1, statements);
74695             var functionDeclaration = factory.createVariableStatement(undefined, ts.setEmitFlags(factory.createVariableDeclarationList([
74696                 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))
74697             ]), 2097152));
74698             var part = factory.createVariableDeclarationList(ts.map(currentState.loopOutParameters, createOutVariable));
74699             return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part };
74700         }
74701         function createFunctionForBodyOfIterationStatement(node, currentState, outerState) {
74702             var functionName = factory.createUniqueName("_loop");
74703             startLexicalEnvironment();
74704             var statement = ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock);
74705             var lexicalEnvironment = endLexicalEnvironment();
74706             var statements = [];
74707             if (shouldConvertConditionOfForStatement(node) || shouldConvertIncrementorOfForStatement(node)) {
74708                 currentState.conditionVariable = factory.createUniqueName("inc");
74709                 if (node.incrementor) {
74710                     statements.push(factory.createIfStatement(currentState.conditionVariable, factory.createExpressionStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), factory.createExpressionStatement(factory.createAssignment(currentState.conditionVariable, factory.createTrue()))));
74711                 }
74712                 else {
74713                     statements.push(factory.createIfStatement(factory.createLogicalNot(currentState.conditionVariable), factory.createExpressionStatement(factory.createAssignment(currentState.conditionVariable, factory.createTrue()))));
74714                 }
74715                 if (shouldConvertConditionOfForStatement(node)) {
74716                     statements.push(factory.createIfStatement(factory.createPrefixUnaryExpression(53, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(factory.createBreakStatement(), visitor, ts.isStatement)));
74717                 }
74718             }
74719             if (ts.isBlock(statement)) {
74720                 ts.addRange(statements, statement.statements);
74721             }
74722             else {
74723                 statements.push(statement);
74724             }
74725             copyOutParameters(currentState.loopOutParameters, 1, 1, statements);
74726             ts.insertStatementsAfterStandardPrologue(statements, lexicalEnvironment);
74727             var loopBody = factory.createBlock(statements, true);
74728             if (ts.isBlock(statement))
74729                 ts.setOriginalNode(loopBody, statement);
74730             var containsYield = (node.statement.transformFlags & 262144) !== 0;
74731             var emitFlags = 0;
74732             if (currentState.containsLexicalThis)
74733                 emitFlags |= 8;
74734             if (containsYield && (hierarchyFacts & 4) !== 0)
74735                 emitFlags |= 262144;
74736             var functionDeclaration = factory.createVariableStatement(undefined, ts.setEmitFlags(factory.createVariableDeclarationList([
74737                 factory.createVariableDeclaration(functionName, undefined, undefined, ts.setEmitFlags(factory.createFunctionExpression(undefined, containsYield ? factory.createToken(41) : undefined, undefined, undefined, currentState.loopParameters, undefined, loopBody), emitFlags))
74738             ]), 2097152));
74739             var part = generateCallToConvertedLoop(functionName, currentState, outerState, containsYield);
74740             return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part };
74741         }
74742         function copyOutParameter(outParam, copyDirection) {
74743             var source = copyDirection === 0 ? outParam.outParamName : outParam.originalName;
74744             var target = copyDirection === 0 ? outParam.originalName : outParam.outParamName;
74745             return factory.createBinaryExpression(target, 62, source);
74746         }
74747         function copyOutParameters(outParams, partFlags, copyDirection, statements) {
74748             for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) {
74749                 var outParam = outParams_1[_i];
74750                 if (outParam.flags & partFlags) {
74751                     statements.push(factory.createExpressionStatement(copyOutParameter(outParam, copyDirection)));
74752                 }
74753             }
74754         }
74755         function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) {
74756             var call = factory.createCallExpression(initFunctionExpressionName, undefined, []);
74757             var callResult = containsYield
74758                 ? factory.createYieldExpression(factory.createToken(41), ts.setEmitFlags(call, 8388608))
74759                 : call;
74760             return factory.createExpressionStatement(callResult);
74761         }
74762         function generateCallToConvertedLoop(loopFunctionExpressionName, state, outerState, containsYield) {
74763             var statements = [];
74764             var isSimpleLoop = !(state.nonLocalJumps & ~4) &&
74765                 !state.labeledNonLocalBreaks &&
74766                 !state.labeledNonLocalContinues;
74767             var call = factory.createCallExpression(loopFunctionExpressionName, undefined, ts.map(state.loopParameters, function (p) { return p.name; }));
74768             var callResult = containsYield
74769                 ? factory.createYieldExpression(factory.createToken(41), ts.setEmitFlags(call, 8388608))
74770                 : call;
74771             if (isSimpleLoop) {
74772                 statements.push(factory.createExpressionStatement(callResult));
74773                 copyOutParameters(state.loopOutParameters, 1, 0, statements);
74774             }
74775             else {
74776                 var loopResultName = factory.createUniqueName("state");
74777                 var stateVariable = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(loopResultName, undefined, undefined, callResult)]));
74778                 statements.push(stateVariable);
74779                 copyOutParameters(state.loopOutParameters, 1, 0, statements);
74780                 if (state.nonLocalJumps & 8) {
74781                     var returnStatement = void 0;
74782                     if (outerState) {
74783                         outerState.nonLocalJumps |= 8;
74784                         returnStatement = factory.createReturnStatement(loopResultName);
74785                     }
74786                     else {
74787                         returnStatement = factory.createReturnStatement(factory.createPropertyAccessExpression(loopResultName, "value"));
74788                     }
74789                     statements.push(factory.createIfStatement(factory.createTypeCheck(loopResultName, "object"), returnStatement));
74790                 }
74791                 if (state.nonLocalJumps & 2) {
74792                     statements.push(factory.createIfStatement(factory.createStrictEquality(loopResultName, factory.createStringLiteral("break")), factory.createBreakStatement()));
74793                 }
74794                 if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) {
74795                     var caseClauses = [];
74796                     processLabeledJumps(state.labeledNonLocalBreaks, true, loopResultName, outerState, caseClauses);
74797                     processLabeledJumps(state.labeledNonLocalContinues, false, loopResultName, outerState, caseClauses);
74798                     statements.push(factory.createSwitchStatement(loopResultName, factory.createCaseBlock(caseClauses)));
74799                 }
74800             }
74801             return statements;
74802         }
74803         function setLabeledJump(state, isBreak, labelText, labelMarker) {
74804             if (isBreak) {
74805                 if (!state.labeledNonLocalBreaks) {
74806                     state.labeledNonLocalBreaks = new ts.Map();
74807                 }
74808                 state.labeledNonLocalBreaks.set(labelText, labelMarker);
74809             }
74810             else {
74811                 if (!state.labeledNonLocalContinues) {
74812                     state.labeledNonLocalContinues = new ts.Map();
74813                 }
74814                 state.labeledNonLocalContinues.set(labelText, labelMarker);
74815             }
74816         }
74817         function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) {
74818             if (!table) {
74819                 return;
74820             }
74821             table.forEach(function (labelMarker, labelText) {
74822                 var statements = [];
74823                 if (!outerLoop || (outerLoop.labels && outerLoop.labels.get(labelText))) {
74824                     var label = factory.createIdentifier(labelText);
74825                     statements.push(isBreak ? factory.createBreakStatement(label) : factory.createContinueStatement(label));
74826                 }
74827                 else {
74828                     setLabeledJump(outerLoop, isBreak, labelText, labelMarker);
74829                     statements.push(factory.createReturnStatement(loopResultName));
74830                 }
74831                 caseClauses.push(factory.createCaseClause(factory.createStringLiteral(labelMarker), statements));
74832             });
74833         }
74834         function processLoopVariableDeclaration(container, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer) {
74835             var name = decl.name;
74836             if (ts.isBindingPattern(name)) {
74837                 for (var _i = 0, _a = name.elements; _i < _a.length; _i++) {
74838                     var element = _a[_i];
74839                     if (!ts.isOmittedExpression(element)) {
74840                         processLoopVariableDeclaration(container, element, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
74841                     }
74842                 }
74843             }
74844             else {
74845                 loopParameters.push(factory.createParameterDeclaration(undefined, undefined, undefined, name));
74846                 var checkFlags = resolver.getNodeCheckFlags(decl);
74847                 if (checkFlags & 4194304 || hasCapturedBindingsInForInitializer) {
74848                     var outParamName = factory.createUniqueName("out_" + ts.idText(name));
74849                     var flags = 0;
74850                     if (checkFlags & 4194304) {
74851                         flags |= 1;
74852                     }
74853                     if (ts.isForStatement(container) && container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) {
74854                         flags |= 2;
74855                     }
74856                     loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName });
74857                 }
74858             }
74859         }
74860         function addObjectLiteralMembers(expressions, node, receiver, start) {
74861             var properties = node.properties;
74862             var numProperties = properties.length;
74863             for (var i = start; i < numProperties; i++) {
74864                 var property = properties[i];
74865                 switch (property.kind) {
74866                     case 167:
74867                     case 168:
74868                         var accessors = ts.getAllAccessorDeclarations(node.properties, property);
74869                         if (property === accessors.firstAccessor) {
74870                             expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine));
74871                         }
74872                         break;
74873                     case 165:
74874                         expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine));
74875                         break;
74876                     case 288:
74877                         expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine));
74878                         break;
74879                     case 289:
74880                         expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine));
74881                         break;
74882                     default:
74883                         ts.Debug.failBadSyntaxKind(node);
74884                         break;
74885                 }
74886             }
74887         }
74888         function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) {
74889             var expression = factory.createAssignment(ts.createMemberAccessForPropertyName(factory, receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression));
74890             ts.setTextRange(expression, property);
74891             if (startsOnNewLine) {
74892                 ts.startOnNewLine(expression);
74893             }
74894             return expression;
74895         }
74896         function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) {
74897             var expression = factory.createAssignment(ts.createMemberAccessForPropertyName(factory, receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), factory.cloneNode(property.name));
74898             ts.setTextRange(expression, property);
74899             if (startsOnNewLine) {
74900                 ts.startOnNewLine(expression);
74901             }
74902             return expression;
74903         }
74904         function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) {
74905             var expression = factory.createAssignment(ts.createMemberAccessForPropertyName(factory, receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined, container));
74906             ts.setTextRange(expression, method);
74907             if (startsOnNewLine) {
74908                 ts.startOnNewLine(expression);
74909             }
74910             return expression;
74911         }
74912         function visitCatchClause(node) {
74913             var ancestorFacts = enterSubtree(7104, 0);
74914             var updated;
74915             ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015.");
74916             if (ts.isBindingPattern(node.variableDeclaration.name)) {
74917                 var temp = factory.createTempVariable(undefined);
74918                 var newVariableDeclaration = factory.createVariableDeclaration(temp);
74919                 ts.setTextRange(newVariableDeclaration, node.variableDeclaration);
74920                 var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp);
74921                 var list = factory.createVariableDeclarationList(vars);
74922                 ts.setTextRange(list, node.variableDeclaration);
74923                 var destructure = factory.createVariableStatement(undefined, list);
74924                 updated = factory.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure));
74925             }
74926             else {
74927                 updated = ts.visitEachChild(node, visitor, context);
74928             }
74929             exitSubtree(ancestorFacts, 0, 0);
74930             return updated;
74931         }
74932         function addStatementToStartOfBlock(block, statement) {
74933             var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement);
74934             return factory.updateBlock(block, __spreadArrays([statement], transformedStatements));
74935         }
74936         function visitMethodDeclaration(node) {
74937             ts.Debug.assert(!ts.isComputedPropertyName(node.name));
74938             var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined, undefined);
74939             ts.setEmitFlags(functionExpression, 512 | ts.getEmitFlags(functionExpression));
74940             return ts.setTextRange(factory.createPropertyAssignment(node.name, functionExpression), node);
74941         }
74942         function visitAccessorDeclaration(node) {
74943             ts.Debug.assert(!ts.isComputedPropertyName(node.name));
74944             var savedConvertedLoopState = convertedLoopState;
74945             convertedLoopState = undefined;
74946             var ancestorFacts = enterSubtree(16286, 65);
74947             var updated;
74948             var parameters = ts.visitParameterList(node.parameters, visitor, context);
74949             var body = transformFunctionBody(node);
74950             if (node.kind === 167) {
74951                 updated = factory.updateGetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, node.type, body);
74952             }
74953             else {
74954                 updated = factory.updateSetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, body);
74955             }
74956             exitSubtree(ancestorFacts, 49152, 0);
74957             convertedLoopState = savedConvertedLoopState;
74958             return updated;
74959         }
74960         function visitShorthandPropertyAssignment(node) {
74961             return ts.setTextRange(factory.createPropertyAssignment(node.name, visitIdentifier(factory.cloneNode(node.name))), node);
74962         }
74963         function visitComputedPropertyName(node) {
74964             return ts.visitEachChild(node, visitor, context);
74965         }
74966         function visitYieldExpression(node) {
74967             return ts.visitEachChild(node, visitor, context);
74968         }
74969         function visitArrayLiteralExpression(node) {
74970             if (ts.some(node.elements, ts.isSpreadElement)) {
74971                 return transformAndSpreadElements(node.elements, true, !!node.multiLine, !!node.elements.hasTrailingComma);
74972             }
74973             return ts.visitEachChild(node, visitor, context);
74974         }
74975         function visitCallExpression(node) {
74976             if (ts.getEmitFlags(node) & 33554432) {
74977                 return visitTypeScriptClassWrapper(node);
74978             }
74979             var expression = ts.skipOuterExpressions(node.expression);
74980             if (expression.kind === 105 ||
74981                 ts.isSuperProperty(expression) ||
74982                 ts.some(node.arguments, ts.isSpreadElement)) {
74983                 return visitCallExpressionWithPotentialCapturedThisAssignment(node, true);
74984             }
74985             return factory.updateCallExpression(node, ts.visitNode(node.expression, callExpressionVisitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression));
74986         }
74987         function visitTypeScriptClassWrapper(node) {
74988             var body = ts.cast(ts.cast(ts.skipOuterExpressions(node.expression), ts.isArrowFunction).body, ts.isBlock);
74989             var isVariableStatementWithInitializer = function (stmt) { return ts.isVariableStatement(stmt) && !!ts.first(stmt.declarationList.declarations).initializer; };
74990             var savedConvertedLoopState = convertedLoopState;
74991             convertedLoopState = undefined;
74992             var bodyStatements = ts.visitNodes(body.statements, visitor, ts.isStatement);
74993             convertedLoopState = savedConvertedLoopState;
74994             var classStatements = ts.filter(bodyStatements, isVariableStatementWithInitializer);
74995             var remainingStatements = ts.filter(bodyStatements, function (stmt) { return !isVariableStatementWithInitializer(stmt); });
74996             var varStatement = ts.cast(ts.first(classStatements), ts.isVariableStatement);
74997             var variable = varStatement.declarationList.declarations[0];
74998             var initializer = ts.skipOuterExpressions(variable.initializer);
74999             var aliasAssignment = ts.tryCast(initializer, ts.isAssignmentExpression);
75000             var call = ts.cast(aliasAssignment ? ts.skipOuterExpressions(aliasAssignment.right) : initializer, ts.isCallExpression);
75001             var func = ts.cast(ts.skipOuterExpressions(call.expression), ts.isFunctionExpression);
75002             var funcStatements = func.body.statements;
75003             var classBodyStart = 0;
75004             var classBodyEnd = -1;
75005             var statements = [];
75006             if (aliasAssignment) {
75007                 var extendsCall = ts.tryCast(funcStatements[classBodyStart], ts.isExpressionStatement);
75008                 if (extendsCall) {
75009                     statements.push(extendsCall);
75010                     classBodyStart++;
75011                 }
75012                 statements.push(funcStatements[classBodyStart]);
75013                 classBodyStart++;
75014                 statements.push(factory.createExpressionStatement(factory.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier))));
75015             }
75016             while (!ts.isReturnStatement(ts.elementAt(funcStatements, classBodyEnd))) {
75017                 classBodyEnd--;
75018             }
75019             ts.addRange(statements, funcStatements, classBodyStart, classBodyEnd);
75020             if (classBodyEnd < -1) {
75021                 ts.addRange(statements, funcStatements, classBodyEnd + 1);
75022             }
75023             ts.addRange(statements, remainingStatements);
75024             ts.addRange(statements, classStatements, 1);
75025             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))));
75026         }
75027         function visitImmediateSuperCallInBody(node) {
75028             return visitCallExpressionWithPotentialCapturedThisAssignment(node, false);
75029         }
75030         function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
75031             if (node.transformFlags & 8192 ||
75032                 node.expression.kind === 105 ||
75033                 ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) {
75034                 var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
75035                 if (node.expression.kind === 105) {
75036                     ts.setEmitFlags(thisArg, 4);
75037                 }
75038                 var resultingCall = void 0;
75039                 if (node.transformFlags & 8192) {
75040                     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));
75041                 }
75042                 else {
75043                     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);
75044                 }
75045                 if (node.expression.kind === 105) {
75046                     var initializer = factory.createLogicalOr(resultingCall, createActualThis());
75047                     resultingCall = assignToCapturedThis
75048                         ? factory.createAssignment(factory.createUniqueName("_this", 16 | 32), initializer)
75049                         : initializer;
75050                 }
75051                 return ts.setOriginalNode(resultingCall, node);
75052             }
75053             return ts.visitEachChild(node, visitor, context);
75054         }
75055         function visitNewExpression(node) {
75056             if (ts.some(node.arguments, ts.isSpreadElement)) {
75057                 var _a = factory.createCallBinding(factory.createPropertyAccessExpression(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
75058                 return factory.createNewExpression(factory.createFunctionApplyCall(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(factory.createNodeArray(__spreadArrays([factory.createVoidZero()], node.arguments)), false, false, false)), undefined, []);
75059             }
75060             return ts.visitEachChild(node, visitor, context);
75061         }
75062         function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) {
75063             var numElements = elements.length;
75064             var segments = ts.flatten(ts.spanMap(elements, partitionSpread, function (partition, visitPartition, _start, end) {
75065                 return visitPartition(partition, multiLine, hasTrailingComma && end === numElements);
75066             }));
75067             if (compilerOptions.downlevelIteration) {
75068                 if (segments.length === 1) {
75069                     var firstSegment = segments[0];
75070                     if (isCallToHelper(firstSegment, "___spread")) {
75071                         return segments[0];
75072                     }
75073                 }
75074                 return emitHelpers().createSpreadHelper(segments);
75075             }
75076             else {
75077                 if (segments.length === 1) {
75078                     var firstSegment = segments[0];
75079                     if (!needsUniqueCopy
75080                         || isPackedArrayLiteral(firstSegment)
75081                         || isCallToHelper(firstSegment, "___spreadArrays")) {
75082                         return segments[0];
75083                     }
75084                 }
75085                 return emitHelpers().createSpreadArraysHelper(segments);
75086             }
75087         }
75088         function isPackedElement(node) {
75089             return !ts.isOmittedExpression(node);
75090         }
75091         function isPackedArrayLiteral(node) {
75092             return ts.isArrayLiteralExpression(node) && ts.every(node.elements, isPackedElement);
75093         }
75094         function isCallToHelper(firstSegment, helperName) {
75095             return ts.isCallExpression(firstSegment)
75096                 && ts.isIdentifier(firstSegment.expression)
75097                 && (ts.getEmitFlags(firstSegment.expression) & 4096)
75098                 && firstSegment.expression.escapedText === helperName;
75099         }
75100         function partitionSpread(node) {
75101             return ts.isSpreadElement(node)
75102                 ? visitSpanOfSpreads
75103                 : visitSpanOfNonSpreads;
75104         }
75105         function visitSpanOfSpreads(chunk) {
75106             return ts.map(chunk, visitExpressionOfSpread);
75107         }
75108         function visitSpanOfNonSpreads(chunk, multiLine, hasTrailingComma) {
75109             return factory.createArrayLiteralExpression(ts.visitNodes(factory.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine);
75110         }
75111         function visitSpreadElement(node) {
75112             return ts.visitNode(node.expression, visitor, ts.isExpression);
75113         }
75114         function visitExpressionOfSpread(node) {
75115             return ts.visitNode(node.expression, visitor, ts.isExpression);
75116         }
75117         function visitTemplateLiteral(node) {
75118             return ts.setTextRange(factory.createStringLiteral(node.text), node);
75119         }
75120         function visitStringLiteral(node) {
75121             if (node.hasExtendedUnicodeEscape) {
75122                 return ts.setTextRange(factory.createStringLiteral(node.text), node);
75123             }
75124             return node;
75125         }
75126         function visitNumericLiteral(node) {
75127             if (node.numericLiteralFlags & 384) {
75128                 return ts.setTextRange(factory.createNumericLiteral(node.text), node);
75129             }
75130             return node;
75131         }
75132         function visitTaggedTemplateExpression(node) {
75133             return ts.processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, ts.ProcessLevel.All);
75134         }
75135         function visitTemplateExpression(node) {
75136             var expressions = [];
75137             addTemplateHead(expressions, node);
75138             addTemplateSpans(expressions, node);
75139             var expression = ts.reduceLeft(expressions, factory.createAdd);
75140             if (ts.nodeIsSynthesized(expression)) {
75141                 ts.setTextRange(expression, node);
75142             }
75143             return expression;
75144         }
75145         function shouldAddTemplateHead(node) {
75146             ts.Debug.assert(node.templateSpans.length !== 0);
75147             return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0;
75148         }
75149         function addTemplateHead(expressions, node) {
75150             if (!shouldAddTemplateHead(node)) {
75151                 return;
75152             }
75153             expressions.push(factory.createStringLiteral(node.head.text));
75154         }
75155         function addTemplateSpans(expressions, node) {
75156             for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) {
75157                 var span = _a[_i];
75158                 expressions.push(ts.visitNode(span.expression, visitor, ts.isExpression));
75159                 if (span.literal.text.length !== 0) {
75160                     expressions.push(factory.createStringLiteral(span.literal.text));
75161                 }
75162             }
75163         }
75164         function visitSuperKeyword(isExpressionOfCall) {
75165             return hierarchyFacts & 8
75166                 && !isExpressionOfCall
75167                 ? factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 | 32), "prototype")
75168                 : factory.createUniqueName("_super", 16 | 32);
75169         }
75170         function visitMetaProperty(node) {
75171             if (node.keywordToken === 102 && node.name.escapedText === "target") {
75172                 hierarchyFacts |= 16384;
75173                 return factory.createUniqueName("_newTarget", 16 | 32);
75174             }
75175             return node;
75176         }
75177         function onEmitNode(hint, node, emitCallback) {
75178             if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) {
75179                 var ancestorFacts = enterSubtree(16286, ts.getEmitFlags(node) & 8
75180                     ? 65 | 16
75181                     : 65);
75182                 previousOnEmitNode(hint, node, emitCallback);
75183                 exitSubtree(ancestorFacts, 0, 0);
75184                 return;
75185             }
75186             previousOnEmitNode(hint, node, emitCallback);
75187         }
75188         function enableSubstitutionsForBlockScopedBindings() {
75189             if ((enabledSubstitutions & 2) === 0) {
75190                 enabledSubstitutions |= 2;
75191                 context.enableSubstitution(78);
75192             }
75193         }
75194         function enableSubstitutionsForCapturedThis() {
75195             if ((enabledSubstitutions & 1) === 0) {
75196                 enabledSubstitutions |= 1;
75197                 context.enableSubstitution(107);
75198                 context.enableEmitNotification(166);
75199                 context.enableEmitNotification(165);
75200                 context.enableEmitNotification(167);
75201                 context.enableEmitNotification(168);
75202                 context.enableEmitNotification(209);
75203                 context.enableEmitNotification(208);
75204                 context.enableEmitNotification(251);
75205             }
75206         }
75207         function onSubstituteNode(hint, node) {
75208             node = previousOnSubstituteNode(hint, node);
75209             if (hint === 1) {
75210                 return substituteExpression(node);
75211             }
75212             if (ts.isIdentifier(node)) {
75213                 return substituteIdentifier(node);
75214             }
75215             return node;
75216         }
75217         function substituteIdentifier(node) {
75218             if (enabledSubstitutions & 2 && !ts.isInternalName(node)) {
75219                 var original = ts.getParseTreeNode(node, ts.isIdentifier);
75220                 if (original && isNameOfDeclarationWithCollidingName(original)) {
75221                     return ts.setTextRange(factory.getGeneratedNameForNode(original), node);
75222                 }
75223             }
75224             return node;
75225         }
75226         function isNameOfDeclarationWithCollidingName(node) {
75227             switch (node.parent.kind) {
75228                 case 198:
75229                 case 252:
75230                 case 255:
75231                 case 249:
75232                     return node.parent.name === node
75233                         && resolver.isDeclarationWithCollidingName(node.parent);
75234             }
75235             return false;
75236         }
75237         function substituteExpression(node) {
75238             switch (node.kind) {
75239                 case 78:
75240                     return substituteExpressionIdentifier(node);
75241                 case 107:
75242                     return substituteThisKeyword(node);
75243             }
75244             return node;
75245         }
75246         function substituteExpressionIdentifier(node) {
75247             if (enabledSubstitutions & 2 && !ts.isInternalName(node)) {
75248                 var declaration = resolver.getReferencedDeclarationWithCollidingName(node);
75249                 if (declaration && !(ts.isClassLike(declaration) && isPartOfClassBody(declaration, node))) {
75250                     return ts.setTextRange(factory.getGeneratedNameForNode(ts.getNameOfDeclaration(declaration)), node);
75251                 }
75252             }
75253             return node;
75254         }
75255         function isPartOfClassBody(declaration, node) {
75256             var currentNode = ts.getParseTreeNode(node);
75257             if (!currentNode || currentNode === declaration || currentNode.end <= declaration.pos || currentNode.pos >= declaration.end) {
75258                 return false;
75259             }
75260             var blockScope = ts.getEnclosingBlockScopeContainer(declaration);
75261             while (currentNode) {
75262                 if (currentNode === blockScope || currentNode === declaration) {
75263                     return false;
75264                 }
75265                 if (ts.isClassElement(currentNode) && currentNode.parent === declaration) {
75266                     return true;
75267                 }
75268                 currentNode = currentNode.parent;
75269             }
75270             return false;
75271         }
75272         function substituteThisKeyword(node) {
75273             if (enabledSubstitutions & 1
75274                 && hierarchyFacts & 16) {
75275                 return ts.setTextRange(factory.createUniqueName("_this", 16 | 32), node);
75276             }
75277             return node;
75278         }
75279         function getClassMemberPrefix(node, member) {
75280             return ts.hasSyntacticModifier(member, 32)
75281                 ? factory.getInternalName(node)
75282                 : factory.createPropertyAccessExpression(factory.getInternalName(node), "prototype");
75283         }
75284         function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) {
75285             if (!constructor || !hasExtendsClause) {
75286                 return false;
75287             }
75288             if (ts.some(constructor.parameters)) {
75289                 return false;
75290             }
75291             var statement = ts.firstOrUndefined(constructor.body.statements);
75292             if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 233) {
75293                 return false;
75294             }
75295             var statementExpression = statement.expression;
75296             if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 203) {
75297                 return false;
75298             }
75299             var callTarget = statementExpression.expression;
75300             if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 105) {
75301                 return false;
75302             }
75303             var callArgument = ts.singleOrUndefined(statementExpression.arguments);
75304             if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 220) {
75305                 return false;
75306             }
75307             var expression = callArgument.expression;
75308             return ts.isIdentifier(expression) && expression.escapedText === "arguments";
75309         }
75310     }
75311     ts.transformES2015 = transformES2015;
75312 })(ts || (ts = {}));
75313 var ts;
75314 (function (ts) {
75315     function transformES5(context) {
75316         var factory = context.factory;
75317         var compilerOptions = context.getCompilerOptions();
75318         var previousOnEmitNode;
75319         var noSubstitution;
75320         if (compilerOptions.jsx === 1 || compilerOptions.jsx === 3) {
75321             previousOnEmitNode = context.onEmitNode;
75322             context.onEmitNode = onEmitNode;
75323             context.enableEmitNotification(275);
75324             context.enableEmitNotification(276);
75325             context.enableEmitNotification(274);
75326             noSubstitution = [];
75327         }
75328         var previousOnSubstituteNode = context.onSubstituteNode;
75329         context.onSubstituteNode = onSubstituteNode;
75330         context.enableSubstitution(201);
75331         context.enableSubstitution(288);
75332         return ts.chainBundle(context, transformSourceFile);
75333         function transformSourceFile(node) {
75334             return node;
75335         }
75336         function onEmitNode(hint, node, emitCallback) {
75337             switch (node.kind) {
75338                 case 275:
75339                 case 276:
75340                 case 274:
75341                     var tagName = node.tagName;
75342                     noSubstitution[ts.getOriginalNodeId(tagName)] = true;
75343                     break;
75344             }
75345             previousOnEmitNode(hint, node, emitCallback);
75346         }
75347         function onSubstituteNode(hint, node) {
75348             if (node.id && noSubstitution && noSubstitution[node.id]) {
75349                 return previousOnSubstituteNode(hint, node);
75350             }
75351             node = previousOnSubstituteNode(hint, node);
75352             if (ts.isPropertyAccessExpression(node)) {
75353                 return substitutePropertyAccessExpression(node);
75354             }
75355             else if (ts.isPropertyAssignment(node)) {
75356                 return substitutePropertyAssignment(node);
75357             }
75358             return node;
75359         }
75360         function substitutePropertyAccessExpression(node) {
75361             if (ts.isPrivateIdentifier(node.name)) {
75362                 return node;
75363             }
75364             var literalName = trySubstituteReservedName(node.name);
75365             if (literalName) {
75366                 return ts.setTextRange(factory.createElementAccessExpression(node.expression, literalName), node);
75367             }
75368             return node;
75369         }
75370         function substitutePropertyAssignment(node) {
75371             var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name);
75372             if (literalName) {
75373                 return factory.updatePropertyAssignment(node, literalName, node.initializer);
75374             }
75375             return node;
75376         }
75377         function trySubstituteReservedName(name) {
75378             var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined);
75379             if (token !== undefined && token >= 80 && token <= 115) {
75380                 return ts.setTextRange(factory.createStringLiteralFromNode(name), name);
75381             }
75382             return undefined;
75383         }
75384     }
75385     ts.transformES5 = transformES5;
75386 })(ts || (ts = {}));
75387 var ts;
75388 (function (ts) {
75389     function getInstructionName(instruction) {
75390         switch (instruction) {
75391             case 2: return "return";
75392             case 3: return "break";
75393             case 4: return "yield";
75394             case 5: return "yield*";
75395             case 7: return "endfinally";
75396             default: return undefined;
75397         }
75398     }
75399     function transformGenerators(context) {
75400         var factory = context.factory, emitHelpers = context.getEmitHelperFactory, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration;
75401         var compilerOptions = context.getCompilerOptions();
75402         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
75403         var resolver = context.getEmitResolver();
75404         var previousOnSubstituteNode = context.onSubstituteNode;
75405         context.onSubstituteNode = onSubstituteNode;
75406         var renamedCatchVariables;
75407         var renamedCatchVariableDeclarations;
75408         var inGeneratorFunctionBody;
75409         var inStatementContainingYield;
75410         var blocks;
75411         var blockOffsets;
75412         var blockActions;
75413         var blockStack;
75414         var labelOffsets;
75415         var labelExpressions;
75416         var nextLabelId = 1;
75417         var operations;
75418         var operationArguments;
75419         var operationLocations;
75420         var state;
75421         var blockIndex = 0;
75422         var labelNumber = 0;
75423         var labelNumbers;
75424         var lastOperationWasAbrupt;
75425         var lastOperationWasCompletion;
75426         var clauses;
75427         var statements;
75428         var exceptionBlockStack;
75429         var currentExceptionBlock;
75430         var withBlockStack;
75431         return ts.chainBundle(context, transformSourceFile);
75432         function transformSourceFile(node) {
75433             if (node.isDeclarationFile || (node.transformFlags & 512) === 0) {
75434                 return node;
75435             }
75436             var visited = ts.visitEachChild(node, visitor, context);
75437             ts.addEmitHelpers(visited, context.readEmitHelpers());
75438             return visited;
75439         }
75440         function visitor(node) {
75441             var transformFlags = node.transformFlags;
75442             if (inStatementContainingYield) {
75443                 return visitJavaScriptInStatementContainingYield(node);
75444             }
75445             else if (inGeneratorFunctionBody) {
75446                 return visitJavaScriptInGeneratorFunctionBody(node);
75447             }
75448             else if (ts.isFunctionLikeDeclaration(node) && node.asteriskToken) {
75449                 return visitGenerator(node);
75450             }
75451             else if (transformFlags & 512) {
75452                 return ts.visitEachChild(node, visitor, context);
75453             }
75454             else {
75455                 return node;
75456             }
75457         }
75458         function visitJavaScriptInStatementContainingYield(node) {
75459             switch (node.kind) {
75460                 case 235:
75461                     return visitDoStatement(node);
75462                 case 236:
75463                     return visitWhileStatement(node);
75464                 case 244:
75465                     return visitSwitchStatement(node);
75466                 case 245:
75467                     return visitLabeledStatement(node);
75468                 default:
75469                     return visitJavaScriptInGeneratorFunctionBody(node);
75470             }
75471         }
75472         function visitJavaScriptInGeneratorFunctionBody(node) {
75473             switch (node.kind) {
75474                 case 251:
75475                     return visitFunctionDeclaration(node);
75476                 case 208:
75477                     return visitFunctionExpression(node);
75478                 case 167:
75479                 case 168:
75480                     return visitAccessorDeclaration(node);
75481                 case 232:
75482                     return visitVariableStatement(node);
75483                 case 237:
75484                     return visitForStatement(node);
75485                 case 238:
75486                     return visitForInStatement(node);
75487                 case 241:
75488                     return visitBreakStatement(node);
75489                 case 240:
75490                     return visitContinueStatement(node);
75491                 case 242:
75492                     return visitReturnStatement(node);
75493                 default:
75494                     if (node.transformFlags & 262144) {
75495                         return visitJavaScriptContainingYield(node);
75496                     }
75497                     else if (node.transformFlags & (512 | 1048576)) {
75498                         return ts.visitEachChild(node, visitor, context);
75499                     }
75500                     else {
75501                         return node;
75502                     }
75503             }
75504         }
75505         function visitJavaScriptContainingYield(node) {
75506             switch (node.kind) {
75507                 case 216:
75508                     return visitBinaryExpression(node);
75509                 case 337:
75510                     return visitCommaListExpression(node);
75511                 case 217:
75512                     return visitConditionalExpression(node);
75513                 case 219:
75514                     return visitYieldExpression(node);
75515                 case 199:
75516                     return visitArrayLiteralExpression(node);
75517                 case 200:
75518                     return visitObjectLiteralExpression(node);
75519                 case 202:
75520                     return visitElementAccessExpression(node);
75521                 case 203:
75522                     return visitCallExpression(node);
75523                 case 204:
75524                     return visitNewExpression(node);
75525                 default:
75526                     return ts.visitEachChild(node, visitor, context);
75527             }
75528         }
75529         function visitGenerator(node) {
75530             switch (node.kind) {
75531                 case 251:
75532                     return visitFunctionDeclaration(node);
75533                 case 208:
75534                     return visitFunctionExpression(node);
75535                 default:
75536                     return ts.Debug.failBadSyntaxKind(node);
75537             }
75538         }
75539         function visitFunctionDeclaration(node) {
75540             if (node.asteriskToken) {
75541                 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);
75542             }
75543             else {
75544                 var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
75545                 var savedInStatementContainingYield = inStatementContainingYield;
75546                 inGeneratorFunctionBody = false;
75547                 inStatementContainingYield = false;
75548                 node = ts.visitEachChild(node, visitor, context);
75549                 inGeneratorFunctionBody = savedInGeneratorFunctionBody;
75550                 inStatementContainingYield = savedInStatementContainingYield;
75551             }
75552             if (inGeneratorFunctionBody) {
75553                 hoistFunctionDeclaration(node);
75554                 return undefined;
75555             }
75556             else {
75557                 return node;
75558             }
75559         }
75560         function visitFunctionExpression(node) {
75561             if (node.asteriskToken) {
75562                 node = ts.setOriginalNode(ts.setTextRange(factory.createFunctionExpression(undefined, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node);
75563             }
75564             else {
75565                 var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
75566                 var savedInStatementContainingYield = inStatementContainingYield;
75567                 inGeneratorFunctionBody = false;
75568                 inStatementContainingYield = false;
75569                 node = ts.visitEachChild(node, visitor, context);
75570                 inGeneratorFunctionBody = savedInGeneratorFunctionBody;
75571                 inStatementContainingYield = savedInStatementContainingYield;
75572             }
75573             return node;
75574         }
75575         function visitAccessorDeclaration(node) {
75576             var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
75577             var savedInStatementContainingYield = inStatementContainingYield;
75578             inGeneratorFunctionBody = false;
75579             inStatementContainingYield = false;
75580             node = ts.visitEachChild(node, visitor, context);
75581             inGeneratorFunctionBody = savedInGeneratorFunctionBody;
75582             inStatementContainingYield = savedInStatementContainingYield;
75583             return node;
75584         }
75585         function transformGeneratorFunctionBody(body) {
75586             var statements = [];
75587             var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
75588             var savedInStatementContainingYield = inStatementContainingYield;
75589             var savedBlocks = blocks;
75590             var savedBlockOffsets = blockOffsets;
75591             var savedBlockActions = blockActions;
75592             var savedBlockStack = blockStack;
75593             var savedLabelOffsets = labelOffsets;
75594             var savedLabelExpressions = labelExpressions;
75595             var savedNextLabelId = nextLabelId;
75596             var savedOperations = operations;
75597             var savedOperationArguments = operationArguments;
75598             var savedOperationLocations = operationLocations;
75599             var savedState = state;
75600             inGeneratorFunctionBody = true;
75601             inStatementContainingYield = false;
75602             blocks = undefined;
75603             blockOffsets = undefined;
75604             blockActions = undefined;
75605             blockStack = undefined;
75606             labelOffsets = undefined;
75607             labelExpressions = undefined;
75608             nextLabelId = 1;
75609             operations = undefined;
75610             operationArguments = undefined;
75611             operationLocations = undefined;
75612             state = factory.createTempVariable(undefined);
75613             resumeLexicalEnvironment();
75614             var statementOffset = factory.copyPrologue(body.statements, statements, false, visitor);
75615             transformAndEmitStatements(body.statements, statementOffset);
75616             var buildResult = build();
75617             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
75618             statements.push(factory.createReturnStatement(buildResult));
75619             inGeneratorFunctionBody = savedInGeneratorFunctionBody;
75620             inStatementContainingYield = savedInStatementContainingYield;
75621             blocks = savedBlocks;
75622             blockOffsets = savedBlockOffsets;
75623             blockActions = savedBlockActions;
75624             blockStack = savedBlockStack;
75625             labelOffsets = savedLabelOffsets;
75626             labelExpressions = savedLabelExpressions;
75627             nextLabelId = savedNextLabelId;
75628             operations = savedOperations;
75629             operationArguments = savedOperationArguments;
75630             operationLocations = savedOperationLocations;
75631             state = savedState;
75632             return ts.setTextRange(factory.createBlock(statements, body.multiLine), body);
75633         }
75634         function visitVariableStatement(node) {
75635             if (node.transformFlags & 262144) {
75636                 transformAndEmitVariableDeclarationList(node.declarationList);
75637                 return undefined;
75638             }
75639             else {
75640                 if (ts.getEmitFlags(node) & 1048576) {
75641                     return node;
75642                 }
75643                 for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
75644                     var variable = _a[_i];
75645                     hoistVariableDeclaration(variable.name);
75646                 }
75647                 var variables = ts.getInitializedVariables(node.declarationList);
75648                 if (variables.length === 0) {
75649                     return undefined;
75650                 }
75651                 return ts.setSourceMapRange(factory.createExpressionStatement(factory.inlineExpressions(ts.map(variables, transformInitializedVariable))), node);
75652             }
75653         }
75654         function visitBinaryExpression(node) {
75655             var assoc = ts.getExpressionAssociativity(node);
75656             switch (assoc) {
75657                 case 0:
75658                     return visitLeftAssociativeBinaryExpression(node);
75659                 case 1:
75660                     return visitRightAssociativeBinaryExpression(node);
75661                 default:
75662                     return ts.Debug.assertNever(assoc);
75663             }
75664         }
75665         function visitRightAssociativeBinaryExpression(node) {
75666             var left = node.left, right = node.right;
75667             if (containsYield(right)) {
75668                 var target = void 0;
75669                 switch (left.kind) {
75670                     case 201:
75671                         target = factory.updatePropertyAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name);
75672                         break;
75673                     case 202:
75674                         target = factory.updateElementAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression)));
75675                         break;
75676                     default:
75677                         target = ts.visitNode(left, visitor, ts.isExpression);
75678                         break;
75679                 }
75680                 var operator = node.operatorToken.kind;
75681                 if (ts.isCompoundAssignment(operator)) {
75682                     return ts.setTextRange(factory.createAssignment(target, ts.setTextRange(factory.createBinaryExpression(cacheExpression(target), ts.getNonAssignmentOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression)), node)), node);
75683                 }
75684                 else {
75685                     return factory.updateBinaryExpression(node, target, node.operatorToken, ts.visitNode(right, visitor, ts.isExpression));
75686                 }
75687             }
75688             return ts.visitEachChild(node, visitor, context);
75689         }
75690         function visitLeftAssociativeBinaryExpression(node) {
75691             if (containsYield(node.right)) {
75692                 if (ts.isLogicalOperator(node.operatorToken.kind)) {
75693                     return visitLogicalBinaryExpression(node);
75694                 }
75695                 else if (node.operatorToken.kind === 27) {
75696                     return visitCommaExpression(node);
75697                 }
75698                 return factory.updateBinaryExpression(node, cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)), node.operatorToken, ts.visitNode(node.right, visitor, ts.isExpression));
75699             }
75700             return ts.visitEachChild(node, visitor, context);
75701         }
75702         function visitCommaExpression(node) {
75703             var pendingExpressions = [];
75704             visit(node.left);
75705             visit(node.right);
75706             return factory.inlineExpressions(pendingExpressions);
75707             function visit(node) {
75708                 if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27) {
75709                     visit(node.left);
75710                     visit(node.right);
75711                 }
75712                 else {
75713                     if (containsYield(node) && pendingExpressions.length > 0) {
75714                         emitWorker(1, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]);
75715                         pendingExpressions = [];
75716                     }
75717                     pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression));
75718                 }
75719             }
75720         }
75721         function visitCommaListExpression(node) {
75722             var pendingExpressions = [];
75723             for (var _i = 0, _a = node.elements; _i < _a.length; _i++) {
75724                 var elem = _a[_i];
75725                 if (ts.isBinaryExpression(elem) && elem.operatorToken.kind === 27) {
75726                     pendingExpressions.push(visitCommaExpression(elem));
75727                 }
75728                 else {
75729                     if (containsYield(elem) && pendingExpressions.length > 0) {
75730                         emitWorker(1, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]);
75731                         pendingExpressions = [];
75732                     }
75733                     pendingExpressions.push(ts.visitNode(elem, visitor, ts.isExpression));
75734                 }
75735             }
75736             return factory.inlineExpressions(pendingExpressions);
75737         }
75738         function visitLogicalBinaryExpression(node) {
75739             var resultLabel = defineLabel();
75740             var resultLocal = declareLocal();
75741             emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), node.left);
75742             if (node.operatorToken.kind === 55) {
75743                 emitBreakWhenFalse(resultLabel, resultLocal, node.left);
75744             }
75745             else {
75746                 emitBreakWhenTrue(resultLabel, resultLocal, node.left);
75747             }
75748             emitAssignment(resultLocal, ts.visitNode(node.right, visitor, ts.isExpression), node.right);
75749             markLabel(resultLabel);
75750             return resultLocal;
75751         }
75752         function visitConditionalExpression(node) {
75753             if (containsYield(node.whenTrue) || containsYield(node.whenFalse)) {
75754                 var whenFalseLabel = defineLabel();
75755                 var resultLabel = defineLabel();
75756                 var resultLocal = declareLocal();
75757                 emitBreakWhenFalse(whenFalseLabel, ts.visitNode(node.condition, visitor, ts.isExpression), node.condition);
75758                 emitAssignment(resultLocal, ts.visitNode(node.whenTrue, visitor, ts.isExpression), node.whenTrue);
75759                 emitBreak(resultLabel);
75760                 markLabel(whenFalseLabel);
75761                 emitAssignment(resultLocal, ts.visitNode(node.whenFalse, visitor, ts.isExpression), node.whenFalse);
75762                 markLabel(resultLabel);
75763                 return resultLocal;
75764             }
75765             return ts.visitEachChild(node, visitor, context);
75766         }
75767         function visitYieldExpression(node) {
75768             var resumeLabel = defineLabel();
75769             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
75770             if (node.asteriskToken) {
75771                 var iterator = (ts.getEmitFlags(node.expression) & 8388608) === 0
75772                     ? ts.setTextRange(emitHelpers().createValuesHelper(expression), node)
75773                     : expression;
75774                 emitYieldStar(iterator, node);
75775             }
75776             else {
75777                 emitYield(expression, node);
75778             }
75779             markLabel(resumeLabel);
75780             return createGeneratorResume(node);
75781         }
75782         function visitArrayLiteralExpression(node) {
75783             return visitElements(node.elements, undefined, undefined, node.multiLine);
75784         }
75785         function visitElements(elements, leadingElement, location, multiLine) {
75786             var numInitialElements = countInitialNodesWithoutYield(elements);
75787             var temp;
75788             if (numInitialElements > 0) {
75789                 temp = declareLocal();
75790                 var initialElements = ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements);
75791                 emitAssignment(temp, factory.createArrayLiteralExpression(leadingElement
75792                     ? __spreadArrays([leadingElement], initialElements) : initialElements));
75793                 leadingElement = undefined;
75794             }
75795             var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements);
75796             return temp
75797                 ? factory.createArrayConcatCall(temp, [factory.createArrayLiteralExpression(expressions, multiLine)])
75798                 : ts.setTextRange(factory.createArrayLiteralExpression(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine), location);
75799             function reduceElement(expressions, element) {
75800                 if (containsYield(element) && expressions.length > 0) {
75801                     var hasAssignedTemp = temp !== undefined;
75802                     if (!temp) {
75803                         temp = declareLocal();
75804                     }
75805                     emitAssignment(temp, hasAssignedTemp
75806                         ? factory.createArrayConcatCall(temp, [factory.createArrayLiteralExpression(expressions, multiLine)])
75807                         : factory.createArrayLiteralExpression(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine));
75808                     leadingElement = undefined;
75809                     expressions = [];
75810                 }
75811                 expressions.push(ts.visitNode(element, visitor, ts.isExpression));
75812                 return expressions;
75813             }
75814         }
75815         function visitObjectLiteralExpression(node) {
75816             var properties = node.properties;
75817             var multiLine = node.multiLine;
75818             var numInitialProperties = countInitialNodesWithoutYield(properties);
75819             var temp = declareLocal();
75820             emitAssignment(temp, factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), multiLine));
75821             var expressions = ts.reduceLeft(properties, reduceProperty, [], numInitialProperties);
75822             expressions.push(multiLine ? ts.startOnNewLine(ts.setParent(ts.setTextRange(factory.cloneNode(temp), temp), temp.parent)) : temp);
75823             return factory.inlineExpressions(expressions);
75824             function reduceProperty(expressions, property) {
75825                 if (containsYield(property) && expressions.length > 0) {
75826                     emitStatement(factory.createExpressionStatement(factory.inlineExpressions(expressions)));
75827                     expressions = [];
75828                 }
75829                 var expression = ts.createExpressionForObjectLiteralElementLike(factory, node, property, temp);
75830                 var visited = ts.visitNode(expression, visitor, ts.isExpression);
75831                 if (visited) {
75832                     if (multiLine) {
75833                         ts.startOnNewLine(visited);
75834                     }
75835                     expressions.push(visited);
75836                 }
75837                 return expressions;
75838             }
75839         }
75840         function visitElementAccessExpression(node) {
75841             if (containsYield(node.argumentExpression)) {
75842                 return factory.updateElementAccessExpression(node, cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)), ts.visitNode(node.argumentExpression, visitor, ts.isExpression));
75843             }
75844             return ts.visitEachChild(node, visitor, context);
75845         }
75846         function visitCallExpression(node) {
75847             if (!ts.isImportCall(node) && ts.forEach(node.arguments, containsYield)) {
75848                 var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion, true), target = _a.target, thisArg = _a.thisArg;
75849                 return ts.setOriginalNode(ts.setTextRange(factory.createFunctionApplyCall(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments)), node), node);
75850             }
75851             return ts.visitEachChild(node, visitor, context);
75852         }
75853         function visitNewExpression(node) {
75854             if (ts.forEach(node.arguments, containsYield)) {
75855                 var _a = factory.createCallBinding(factory.createPropertyAccessExpression(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
75856                 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);
75857             }
75858             return ts.visitEachChild(node, visitor, context);
75859         }
75860         function transformAndEmitStatements(statements, start) {
75861             if (start === void 0) { start = 0; }
75862             var numStatements = statements.length;
75863             for (var i = start; i < numStatements; i++) {
75864                 transformAndEmitStatement(statements[i]);
75865             }
75866         }
75867         function transformAndEmitEmbeddedStatement(node) {
75868             if (ts.isBlock(node)) {
75869                 transformAndEmitStatements(node.statements);
75870             }
75871             else {
75872                 transformAndEmitStatement(node);
75873             }
75874         }
75875         function transformAndEmitStatement(node) {
75876             var savedInStatementContainingYield = inStatementContainingYield;
75877             if (!inStatementContainingYield) {
75878                 inStatementContainingYield = containsYield(node);
75879             }
75880             transformAndEmitStatementWorker(node);
75881             inStatementContainingYield = savedInStatementContainingYield;
75882         }
75883         function transformAndEmitStatementWorker(node) {
75884             switch (node.kind) {
75885                 case 230:
75886                     return transformAndEmitBlock(node);
75887                 case 233:
75888                     return transformAndEmitExpressionStatement(node);
75889                 case 234:
75890                     return transformAndEmitIfStatement(node);
75891                 case 235:
75892                     return transformAndEmitDoStatement(node);
75893                 case 236:
75894                     return transformAndEmitWhileStatement(node);
75895                 case 237:
75896                     return transformAndEmitForStatement(node);
75897                 case 238:
75898                     return transformAndEmitForInStatement(node);
75899                 case 240:
75900                     return transformAndEmitContinueStatement(node);
75901                 case 241:
75902                     return transformAndEmitBreakStatement(node);
75903                 case 242:
75904                     return transformAndEmitReturnStatement(node);
75905                 case 243:
75906                     return transformAndEmitWithStatement(node);
75907                 case 244:
75908                     return transformAndEmitSwitchStatement(node);
75909                 case 245:
75910                     return transformAndEmitLabeledStatement(node);
75911                 case 246:
75912                     return transformAndEmitThrowStatement(node);
75913                 case 247:
75914                     return transformAndEmitTryStatement(node);
75915                 default:
75916                     return emitStatement(ts.visitNode(node, visitor, ts.isStatement));
75917             }
75918         }
75919         function transformAndEmitBlock(node) {
75920             if (containsYield(node)) {
75921                 transformAndEmitStatements(node.statements);
75922             }
75923             else {
75924                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
75925             }
75926         }
75927         function transformAndEmitExpressionStatement(node) {
75928             emitStatement(ts.visitNode(node, visitor, ts.isStatement));
75929         }
75930         function transformAndEmitVariableDeclarationList(node) {
75931             for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) {
75932                 var variable = _a[_i];
75933                 var name = factory.cloneNode(variable.name);
75934                 ts.setCommentRange(name, variable.name);
75935                 hoistVariableDeclaration(name);
75936             }
75937             var variables = ts.getInitializedVariables(node);
75938             var numVariables = variables.length;
75939             var variablesWritten = 0;
75940             var pendingExpressions = [];
75941             while (variablesWritten < numVariables) {
75942                 for (var i = variablesWritten; i < numVariables; i++) {
75943                     var variable = variables[i];
75944                     if (containsYield(variable.initializer) && pendingExpressions.length > 0) {
75945                         break;
75946                     }
75947                     pendingExpressions.push(transformInitializedVariable(variable));
75948                 }
75949                 if (pendingExpressions.length) {
75950                     emitStatement(factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions)));
75951                     variablesWritten += pendingExpressions.length;
75952                     pendingExpressions = [];
75953                 }
75954             }
75955             return undefined;
75956         }
75957         function transformInitializedVariable(node) {
75958             return ts.setSourceMapRange(factory.createAssignment(ts.setSourceMapRange(factory.cloneNode(node.name), node.name), ts.visitNode(node.initializer, visitor, ts.isExpression)), node);
75959         }
75960         function transformAndEmitIfStatement(node) {
75961             if (containsYield(node)) {
75962                 if (containsYield(node.thenStatement) || containsYield(node.elseStatement)) {
75963                     var endLabel = defineLabel();
75964                     var elseLabel = node.elseStatement ? defineLabel() : undefined;
75965                     emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression), node.expression);
75966                     transformAndEmitEmbeddedStatement(node.thenStatement);
75967                     if (node.elseStatement) {
75968                         emitBreak(endLabel);
75969                         markLabel(elseLabel);
75970                         transformAndEmitEmbeddedStatement(node.elseStatement);
75971                     }
75972                     markLabel(endLabel);
75973                 }
75974                 else {
75975                     emitStatement(ts.visitNode(node, visitor, ts.isStatement));
75976                 }
75977             }
75978             else {
75979                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
75980             }
75981         }
75982         function transformAndEmitDoStatement(node) {
75983             if (containsYield(node)) {
75984                 var conditionLabel = defineLabel();
75985                 var loopLabel = defineLabel();
75986                 beginLoopBlock(conditionLabel);
75987                 markLabel(loopLabel);
75988                 transformAndEmitEmbeddedStatement(node.statement);
75989                 markLabel(conditionLabel);
75990                 emitBreakWhenTrue(loopLabel, ts.visitNode(node.expression, visitor, ts.isExpression));
75991                 endLoopBlock();
75992             }
75993             else {
75994                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
75995             }
75996         }
75997         function visitDoStatement(node) {
75998             if (inStatementContainingYield) {
75999                 beginScriptLoopBlock();
76000                 node = ts.visitEachChild(node, visitor, context);
76001                 endLoopBlock();
76002                 return node;
76003             }
76004             else {
76005                 return ts.visitEachChild(node, visitor, context);
76006             }
76007         }
76008         function transformAndEmitWhileStatement(node) {
76009             if (containsYield(node)) {
76010                 var loopLabel = defineLabel();
76011                 var endLabel = beginLoopBlock(loopLabel);
76012                 markLabel(loopLabel);
76013                 emitBreakWhenFalse(endLabel, ts.visitNode(node.expression, visitor, ts.isExpression));
76014                 transformAndEmitEmbeddedStatement(node.statement);
76015                 emitBreak(loopLabel);
76016                 endLoopBlock();
76017             }
76018             else {
76019                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
76020             }
76021         }
76022         function visitWhileStatement(node) {
76023             if (inStatementContainingYield) {
76024                 beginScriptLoopBlock();
76025                 node = ts.visitEachChild(node, visitor, context);
76026                 endLoopBlock();
76027                 return node;
76028             }
76029             else {
76030                 return ts.visitEachChild(node, visitor, context);
76031             }
76032         }
76033         function transformAndEmitForStatement(node) {
76034             if (containsYield(node)) {
76035                 var conditionLabel = defineLabel();
76036                 var incrementLabel = defineLabel();
76037                 var endLabel = beginLoopBlock(incrementLabel);
76038                 if (node.initializer) {
76039                     var initializer = node.initializer;
76040                     if (ts.isVariableDeclarationList(initializer)) {
76041                         transformAndEmitVariableDeclarationList(initializer);
76042                     }
76043                     else {
76044                         emitStatement(ts.setTextRange(factory.createExpressionStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer));
76045                     }
76046                 }
76047                 markLabel(conditionLabel);
76048                 if (node.condition) {
76049                     emitBreakWhenFalse(endLabel, ts.visitNode(node.condition, visitor, ts.isExpression));
76050                 }
76051                 transformAndEmitEmbeddedStatement(node.statement);
76052                 markLabel(incrementLabel);
76053                 if (node.incrementor) {
76054                     emitStatement(ts.setTextRange(factory.createExpressionStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor));
76055                 }
76056                 emitBreak(conditionLabel);
76057                 endLoopBlock();
76058             }
76059             else {
76060                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
76061             }
76062         }
76063         function visitForStatement(node) {
76064             if (inStatementContainingYield) {
76065                 beginScriptLoopBlock();
76066             }
76067             var initializer = node.initializer;
76068             if (initializer && ts.isVariableDeclarationList(initializer)) {
76069                 for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
76070                     var variable = _a[_i];
76071                     hoistVariableDeclaration(variable.name);
76072                 }
76073                 var variables = ts.getInitializedVariables(initializer);
76074                 node = factory.updateForStatement(node, variables.length > 0
76075                     ? factory.inlineExpressions(ts.map(variables, transformInitializedVariable))
76076                     : undefined, ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock));
76077             }
76078             else {
76079                 node = ts.visitEachChild(node, visitor, context);
76080             }
76081             if (inStatementContainingYield) {
76082                 endLoopBlock();
76083             }
76084             return node;
76085         }
76086         function transformAndEmitForInStatement(node) {
76087             if (containsYield(node)) {
76088                 var keysArray = declareLocal();
76089                 var key = declareLocal();
76090                 var keysIndex = factory.createLoopVariable();
76091                 var initializer = node.initializer;
76092                 hoistVariableDeclaration(keysIndex);
76093                 emitAssignment(keysArray, factory.createArrayLiteralExpression());
76094                 emitStatement(factory.createForInStatement(key, ts.visitNode(node.expression, visitor, ts.isExpression), factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(keysArray, "push"), undefined, [key]))));
76095                 emitAssignment(keysIndex, factory.createNumericLiteral(0));
76096                 var conditionLabel = defineLabel();
76097                 var incrementLabel = defineLabel();
76098                 var endLabel = beginLoopBlock(incrementLabel);
76099                 markLabel(conditionLabel);
76100                 emitBreakWhenFalse(endLabel, factory.createLessThan(keysIndex, factory.createPropertyAccessExpression(keysArray, "length")));
76101                 var variable = void 0;
76102                 if (ts.isVariableDeclarationList(initializer)) {
76103                     for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
76104                         var variable_1 = _a[_i];
76105                         hoistVariableDeclaration(variable_1.name);
76106                     }
76107                     variable = factory.cloneNode(initializer.declarations[0].name);
76108                 }
76109                 else {
76110                     variable = ts.visitNode(initializer, visitor, ts.isExpression);
76111                     ts.Debug.assert(ts.isLeftHandSideExpression(variable));
76112                 }
76113                 emitAssignment(variable, factory.createElementAccessExpression(keysArray, keysIndex));
76114                 transformAndEmitEmbeddedStatement(node.statement);
76115                 markLabel(incrementLabel);
76116                 emitStatement(factory.createExpressionStatement(factory.createPostfixIncrement(keysIndex)));
76117                 emitBreak(conditionLabel);
76118                 endLoopBlock();
76119             }
76120             else {
76121                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
76122             }
76123         }
76124         function visitForInStatement(node) {
76125             if (inStatementContainingYield) {
76126                 beginScriptLoopBlock();
76127             }
76128             var initializer = node.initializer;
76129             if (ts.isVariableDeclarationList(initializer)) {
76130                 for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
76131                     var variable = _a[_i];
76132                     hoistVariableDeclaration(variable.name);
76133                 }
76134                 node = factory.updateForInStatement(node, initializer.declarations[0].name, ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock));
76135             }
76136             else {
76137                 node = ts.visitEachChild(node, visitor, context);
76138             }
76139             if (inStatementContainingYield) {
76140                 endLoopBlock();
76141             }
76142             return node;
76143         }
76144         function transformAndEmitContinueStatement(node) {
76145             var label = findContinueTarget(node.label ? ts.idText(node.label) : undefined);
76146             if (label > 0) {
76147                 emitBreak(label, node);
76148             }
76149             else {
76150                 emitStatement(node);
76151             }
76152         }
76153         function visitContinueStatement(node) {
76154             if (inStatementContainingYield) {
76155                 var label = findContinueTarget(node.label && ts.idText(node.label));
76156                 if (label > 0) {
76157                     return createInlineBreak(label, node);
76158                 }
76159             }
76160             return ts.visitEachChild(node, visitor, context);
76161         }
76162         function transformAndEmitBreakStatement(node) {
76163             var label = findBreakTarget(node.label ? ts.idText(node.label) : undefined);
76164             if (label > 0) {
76165                 emitBreak(label, node);
76166             }
76167             else {
76168                 emitStatement(node);
76169             }
76170         }
76171         function visitBreakStatement(node) {
76172             if (inStatementContainingYield) {
76173                 var label = findBreakTarget(node.label && ts.idText(node.label));
76174                 if (label > 0) {
76175                     return createInlineBreak(label, node);
76176                 }
76177             }
76178             return ts.visitEachChild(node, visitor, context);
76179         }
76180         function transformAndEmitReturnStatement(node) {
76181             emitReturn(ts.visitNode(node.expression, visitor, ts.isExpression), node);
76182         }
76183         function visitReturnStatement(node) {
76184             return createInlineReturn(ts.visitNode(node.expression, visitor, ts.isExpression), node);
76185         }
76186         function transformAndEmitWithStatement(node) {
76187             if (containsYield(node)) {
76188                 beginWithBlock(cacheExpression(ts.visitNode(node.expression, visitor, ts.isExpression)));
76189                 transformAndEmitEmbeddedStatement(node.statement);
76190                 endWithBlock();
76191             }
76192             else {
76193                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
76194             }
76195         }
76196         function transformAndEmitSwitchStatement(node) {
76197             if (containsYield(node.caseBlock)) {
76198                 var caseBlock = node.caseBlock;
76199                 var numClauses = caseBlock.clauses.length;
76200                 var endLabel = beginSwitchBlock();
76201                 var expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isExpression));
76202                 var clauseLabels = [];
76203                 var defaultClauseIndex = -1;
76204                 for (var i = 0; i < numClauses; i++) {
76205                     var clause = caseBlock.clauses[i];
76206                     clauseLabels.push(defineLabel());
76207                     if (clause.kind === 285 && defaultClauseIndex === -1) {
76208                         defaultClauseIndex = i;
76209                     }
76210                 }
76211                 var clausesWritten = 0;
76212                 var pendingClauses = [];
76213                 while (clausesWritten < numClauses) {
76214                     var defaultClausesSkipped = 0;
76215                     for (var i = clausesWritten; i < numClauses; i++) {
76216                         var clause = caseBlock.clauses[i];
76217                         if (clause.kind === 284) {
76218                             if (containsYield(clause.expression) && pendingClauses.length > 0) {
76219                                 break;
76220                             }
76221                             pendingClauses.push(factory.createCaseClause(ts.visitNode(clause.expression, visitor, ts.isExpression), [
76222                                 createInlineBreak(clauseLabels[i], clause.expression)
76223                             ]));
76224                         }
76225                         else {
76226                             defaultClausesSkipped++;
76227                         }
76228                     }
76229                     if (pendingClauses.length) {
76230                         emitStatement(factory.createSwitchStatement(expression, factory.createCaseBlock(pendingClauses)));
76231                         clausesWritten += pendingClauses.length;
76232                         pendingClauses = [];
76233                     }
76234                     if (defaultClausesSkipped > 0) {
76235                         clausesWritten += defaultClausesSkipped;
76236                         defaultClausesSkipped = 0;
76237                     }
76238                 }
76239                 if (defaultClauseIndex >= 0) {
76240                     emitBreak(clauseLabels[defaultClauseIndex]);
76241                 }
76242                 else {
76243                     emitBreak(endLabel);
76244                 }
76245                 for (var i = 0; i < numClauses; i++) {
76246                     markLabel(clauseLabels[i]);
76247                     transformAndEmitStatements(caseBlock.clauses[i].statements);
76248                 }
76249                 endSwitchBlock();
76250             }
76251             else {
76252                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
76253             }
76254         }
76255         function visitSwitchStatement(node) {
76256             if (inStatementContainingYield) {
76257                 beginScriptSwitchBlock();
76258             }
76259             node = ts.visitEachChild(node, visitor, context);
76260             if (inStatementContainingYield) {
76261                 endSwitchBlock();
76262             }
76263             return node;
76264         }
76265         function transformAndEmitLabeledStatement(node) {
76266             if (containsYield(node)) {
76267                 beginLabeledBlock(ts.idText(node.label));
76268                 transformAndEmitEmbeddedStatement(node.statement);
76269                 endLabeledBlock();
76270             }
76271             else {
76272                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
76273             }
76274         }
76275         function visitLabeledStatement(node) {
76276             if (inStatementContainingYield) {
76277                 beginScriptLabeledBlock(ts.idText(node.label));
76278             }
76279             node = ts.visitEachChild(node, visitor, context);
76280             if (inStatementContainingYield) {
76281                 endLabeledBlock();
76282             }
76283             return node;
76284         }
76285         function transformAndEmitThrowStatement(node) {
76286             var _a;
76287             emitThrow(ts.visitNode((_a = node.expression) !== null && _a !== void 0 ? _a : factory.createVoidZero(), visitor, ts.isExpression), node);
76288         }
76289         function transformAndEmitTryStatement(node) {
76290             if (containsYield(node)) {
76291                 beginExceptionBlock();
76292                 transformAndEmitEmbeddedStatement(node.tryBlock);
76293                 if (node.catchClause) {
76294                     beginCatchBlock(node.catchClause.variableDeclaration);
76295                     transformAndEmitEmbeddedStatement(node.catchClause.block);
76296                 }
76297                 if (node.finallyBlock) {
76298                     beginFinallyBlock();
76299                     transformAndEmitEmbeddedStatement(node.finallyBlock);
76300                 }
76301                 endExceptionBlock();
76302             }
76303             else {
76304                 emitStatement(ts.visitEachChild(node, visitor, context));
76305             }
76306         }
76307         function containsYield(node) {
76308             return !!node && (node.transformFlags & 262144) !== 0;
76309         }
76310         function countInitialNodesWithoutYield(nodes) {
76311             var numNodes = nodes.length;
76312             for (var i = 0; i < numNodes; i++) {
76313                 if (containsYield(nodes[i])) {
76314                     return i;
76315                 }
76316             }
76317             return -1;
76318         }
76319         function onSubstituteNode(hint, node) {
76320             node = previousOnSubstituteNode(hint, node);
76321             if (hint === 1) {
76322                 return substituteExpression(node);
76323             }
76324             return node;
76325         }
76326         function substituteExpression(node) {
76327             if (ts.isIdentifier(node)) {
76328                 return substituteExpressionIdentifier(node);
76329             }
76330             return node;
76331         }
76332         function substituteExpressionIdentifier(node) {
76333             if (!ts.isGeneratedIdentifier(node) && renamedCatchVariables && renamedCatchVariables.has(ts.idText(node))) {
76334                 var original = ts.getOriginalNode(node);
76335                 if (ts.isIdentifier(original) && original.parent) {
76336                     var declaration = resolver.getReferencedValueDeclaration(original);
76337                     if (declaration) {
76338                         var name = renamedCatchVariableDeclarations[ts.getOriginalNodeId(declaration)];
76339                         if (name) {
76340                             var clone_5 = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent);
76341                             ts.setSourceMapRange(clone_5, node);
76342                             ts.setCommentRange(clone_5, node);
76343                             return clone_5;
76344                         }
76345                     }
76346                 }
76347             }
76348             return node;
76349         }
76350         function cacheExpression(node) {
76351             if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096) {
76352                 return node;
76353             }
76354             var temp = factory.createTempVariable(hoistVariableDeclaration);
76355             emitAssignment(temp, node, node);
76356             return temp;
76357         }
76358         function declareLocal(name) {
76359             var temp = name
76360                 ? factory.createUniqueName(name)
76361                 : factory.createTempVariable(undefined);
76362             hoistVariableDeclaration(temp);
76363             return temp;
76364         }
76365         function defineLabel() {
76366             if (!labelOffsets) {
76367                 labelOffsets = [];
76368             }
76369             var label = nextLabelId;
76370             nextLabelId++;
76371             labelOffsets[label] = -1;
76372             return label;
76373         }
76374         function markLabel(label) {
76375             ts.Debug.assert(labelOffsets !== undefined, "No labels were defined.");
76376             labelOffsets[label] = operations ? operations.length : 0;
76377         }
76378         function beginBlock(block) {
76379             if (!blocks) {
76380                 blocks = [];
76381                 blockActions = [];
76382                 blockOffsets = [];
76383                 blockStack = [];
76384             }
76385             var index = blockActions.length;
76386             blockActions[index] = 0;
76387             blockOffsets[index] = operations ? operations.length : 0;
76388             blocks[index] = block;
76389             blockStack.push(block);
76390             return index;
76391         }
76392         function endBlock() {
76393             var block = peekBlock();
76394             if (block === undefined)
76395                 return ts.Debug.fail("beginBlock was never called.");
76396             var index = blockActions.length;
76397             blockActions[index] = 1;
76398             blockOffsets[index] = operations ? operations.length : 0;
76399             blocks[index] = block;
76400             blockStack.pop();
76401             return block;
76402         }
76403         function peekBlock() {
76404             return ts.lastOrUndefined(blockStack);
76405         }
76406         function peekBlockKind() {
76407             var block = peekBlock();
76408             return block && block.kind;
76409         }
76410         function beginWithBlock(expression) {
76411             var startLabel = defineLabel();
76412             var endLabel = defineLabel();
76413             markLabel(startLabel);
76414             beginBlock({
76415                 kind: 1,
76416                 expression: expression,
76417                 startLabel: startLabel,
76418                 endLabel: endLabel
76419             });
76420         }
76421         function endWithBlock() {
76422             ts.Debug.assert(peekBlockKind() === 1);
76423             var block = endBlock();
76424             markLabel(block.endLabel);
76425         }
76426         function beginExceptionBlock() {
76427             var startLabel = defineLabel();
76428             var endLabel = defineLabel();
76429             markLabel(startLabel);
76430             beginBlock({
76431                 kind: 0,
76432                 state: 0,
76433                 startLabel: startLabel,
76434                 endLabel: endLabel
76435             });
76436             emitNop();
76437             return endLabel;
76438         }
76439         function beginCatchBlock(variable) {
76440             ts.Debug.assert(peekBlockKind() === 0);
76441             var name;
76442             if (ts.isGeneratedIdentifier(variable.name)) {
76443                 name = variable.name;
76444                 hoistVariableDeclaration(variable.name);
76445             }
76446             else {
76447                 var text = ts.idText(variable.name);
76448                 name = declareLocal(text);
76449                 if (!renamedCatchVariables) {
76450                     renamedCatchVariables = new ts.Map();
76451                     renamedCatchVariableDeclarations = [];
76452                     context.enableSubstitution(78);
76453                 }
76454                 renamedCatchVariables.set(text, true);
76455                 renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name;
76456             }
76457             var exception = peekBlock();
76458             ts.Debug.assert(exception.state < 1);
76459             var endLabel = exception.endLabel;
76460             emitBreak(endLabel);
76461             var catchLabel = defineLabel();
76462             markLabel(catchLabel);
76463             exception.state = 1;
76464             exception.catchVariable = name;
76465             exception.catchLabel = catchLabel;
76466             emitAssignment(name, factory.createCallExpression(factory.createPropertyAccessExpression(state, "sent"), undefined, []));
76467             emitNop();
76468         }
76469         function beginFinallyBlock() {
76470             ts.Debug.assert(peekBlockKind() === 0);
76471             var exception = peekBlock();
76472             ts.Debug.assert(exception.state < 2);
76473             var endLabel = exception.endLabel;
76474             emitBreak(endLabel);
76475             var finallyLabel = defineLabel();
76476             markLabel(finallyLabel);
76477             exception.state = 2;
76478             exception.finallyLabel = finallyLabel;
76479         }
76480         function endExceptionBlock() {
76481             ts.Debug.assert(peekBlockKind() === 0);
76482             var exception = endBlock();
76483             var state = exception.state;
76484             if (state < 2) {
76485                 emitBreak(exception.endLabel);
76486             }
76487             else {
76488                 emitEndfinally();
76489             }
76490             markLabel(exception.endLabel);
76491             emitNop();
76492             exception.state = 3;
76493         }
76494         function beginScriptLoopBlock() {
76495             beginBlock({
76496                 kind: 3,
76497                 isScript: true,
76498                 breakLabel: -1,
76499                 continueLabel: -1
76500             });
76501         }
76502         function beginLoopBlock(continueLabel) {
76503             var breakLabel = defineLabel();
76504             beginBlock({
76505                 kind: 3,
76506                 isScript: false,
76507                 breakLabel: breakLabel,
76508                 continueLabel: continueLabel,
76509             });
76510             return breakLabel;
76511         }
76512         function endLoopBlock() {
76513             ts.Debug.assert(peekBlockKind() === 3);
76514             var block = endBlock();
76515             var breakLabel = block.breakLabel;
76516             if (!block.isScript) {
76517                 markLabel(breakLabel);
76518             }
76519         }
76520         function beginScriptSwitchBlock() {
76521             beginBlock({
76522                 kind: 2,
76523                 isScript: true,
76524                 breakLabel: -1
76525             });
76526         }
76527         function beginSwitchBlock() {
76528             var breakLabel = defineLabel();
76529             beginBlock({
76530                 kind: 2,
76531                 isScript: false,
76532                 breakLabel: breakLabel,
76533             });
76534             return breakLabel;
76535         }
76536         function endSwitchBlock() {
76537             ts.Debug.assert(peekBlockKind() === 2);
76538             var block = endBlock();
76539             var breakLabel = block.breakLabel;
76540             if (!block.isScript) {
76541                 markLabel(breakLabel);
76542             }
76543         }
76544         function beginScriptLabeledBlock(labelText) {
76545             beginBlock({
76546                 kind: 4,
76547                 isScript: true,
76548                 labelText: labelText,
76549                 breakLabel: -1
76550             });
76551         }
76552         function beginLabeledBlock(labelText) {
76553             var breakLabel = defineLabel();
76554             beginBlock({
76555                 kind: 4,
76556                 isScript: false,
76557                 labelText: labelText,
76558                 breakLabel: breakLabel
76559             });
76560         }
76561         function endLabeledBlock() {
76562             ts.Debug.assert(peekBlockKind() === 4);
76563             var block = endBlock();
76564             if (!block.isScript) {
76565                 markLabel(block.breakLabel);
76566             }
76567         }
76568         function supportsUnlabeledBreak(block) {
76569             return block.kind === 2
76570                 || block.kind === 3;
76571         }
76572         function supportsLabeledBreakOrContinue(block) {
76573             return block.kind === 4;
76574         }
76575         function supportsUnlabeledContinue(block) {
76576             return block.kind === 3;
76577         }
76578         function hasImmediateContainingLabeledBlock(labelText, start) {
76579             for (var j = start; j >= 0; j--) {
76580                 var containingBlock = blockStack[j];
76581                 if (supportsLabeledBreakOrContinue(containingBlock)) {
76582                     if (containingBlock.labelText === labelText) {
76583                         return true;
76584                     }
76585                 }
76586                 else {
76587                     break;
76588                 }
76589             }
76590             return false;
76591         }
76592         function findBreakTarget(labelText) {
76593             if (blockStack) {
76594                 if (labelText) {
76595                     for (var i = blockStack.length - 1; i >= 0; i--) {
76596                         var block = blockStack[i];
76597                         if (supportsLabeledBreakOrContinue(block) && block.labelText === labelText) {
76598                             return block.breakLabel;
76599                         }
76600                         else if (supportsUnlabeledBreak(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) {
76601                             return block.breakLabel;
76602                         }
76603                     }
76604                 }
76605                 else {
76606                     for (var i = blockStack.length - 1; i >= 0; i--) {
76607                         var block = blockStack[i];
76608                         if (supportsUnlabeledBreak(block)) {
76609                             return block.breakLabel;
76610                         }
76611                     }
76612                 }
76613             }
76614             return 0;
76615         }
76616         function findContinueTarget(labelText) {
76617             if (blockStack) {
76618                 if (labelText) {
76619                     for (var i = blockStack.length - 1; i >= 0; i--) {
76620                         var block = blockStack[i];
76621                         if (supportsUnlabeledContinue(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) {
76622                             return block.continueLabel;
76623                         }
76624                     }
76625                 }
76626                 else {
76627                     for (var i = blockStack.length - 1; i >= 0; i--) {
76628                         var block = blockStack[i];
76629                         if (supportsUnlabeledContinue(block)) {
76630                             return block.continueLabel;
76631                         }
76632                     }
76633                 }
76634             }
76635             return 0;
76636         }
76637         function createLabel(label) {
76638             if (label !== undefined && label > 0) {
76639                 if (labelExpressions === undefined) {
76640                     labelExpressions = [];
76641                 }
76642                 var expression = factory.createNumericLiteral(-1);
76643                 if (labelExpressions[label] === undefined) {
76644                     labelExpressions[label] = [expression];
76645                 }
76646                 else {
76647                     labelExpressions[label].push(expression);
76648                 }
76649                 return expression;
76650             }
76651             return factory.createOmittedExpression();
76652         }
76653         function createInstruction(instruction) {
76654             var literal = factory.createNumericLiteral(instruction);
76655             ts.addSyntheticTrailingComment(literal, 3, getInstructionName(instruction));
76656             return literal;
76657         }
76658         function createInlineBreak(label, location) {
76659             ts.Debug.assertLessThan(0, label, "Invalid label");
76660             return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([
76661                 createInstruction(3),
76662                 createLabel(label)
76663             ])), location);
76664         }
76665         function createInlineReturn(expression, location) {
76666             return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression
76667                 ? [createInstruction(2), expression]
76668                 : [createInstruction(2)])), location);
76669         }
76670         function createGeneratorResume(location) {
76671             return ts.setTextRange(factory.createCallExpression(factory.createPropertyAccessExpression(state, "sent"), undefined, []), location);
76672         }
76673         function emitNop() {
76674             emitWorker(0);
76675         }
76676         function emitStatement(node) {
76677             if (node) {
76678                 emitWorker(1, [node]);
76679             }
76680             else {
76681                 emitNop();
76682             }
76683         }
76684         function emitAssignment(left, right, location) {
76685             emitWorker(2, [left, right], location);
76686         }
76687         function emitBreak(label, location) {
76688             emitWorker(3, [label], location);
76689         }
76690         function emitBreakWhenTrue(label, condition, location) {
76691             emitWorker(4, [label, condition], location);
76692         }
76693         function emitBreakWhenFalse(label, condition, location) {
76694             emitWorker(5, [label, condition], location);
76695         }
76696         function emitYieldStar(expression, location) {
76697             emitWorker(7, [expression], location);
76698         }
76699         function emitYield(expression, location) {
76700             emitWorker(6, [expression], location);
76701         }
76702         function emitReturn(expression, location) {
76703             emitWorker(8, [expression], location);
76704         }
76705         function emitThrow(expression, location) {
76706             emitWorker(9, [expression], location);
76707         }
76708         function emitEndfinally() {
76709             emitWorker(10);
76710         }
76711         function emitWorker(code, args, location) {
76712             if (operations === undefined) {
76713                 operations = [];
76714                 operationArguments = [];
76715                 operationLocations = [];
76716             }
76717             if (labelOffsets === undefined) {
76718                 markLabel(defineLabel());
76719             }
76720             var operationIndex = operations.length;
76721             operations[operationIndex] = code;
76722             operationArguments[operationIndex] = args;
76723             operationLocations[operationIndex] = location;
76724         }
76725         function build() {
76726             blockIndex = 0;
76727             labelNumber = 0;
76728             labelNumbers = undefined;
76729             lastOperationWasAbrupt = false;
76730             lastOperationWasCompletion = false;
76731             clauses = undefined;
76732             statements = undefined;
76733             exceptionBlockStack = undefined;
76734             currentExceptionBlock = undefined;
76735             withBlockStack = undefined;
76736             var buildResult = buildStatements();
76737             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));
76738         }
76739         function buildStatements() {
76740             if (operations) {
76741                 for (var operationIndex = 0; operationIndex < operations.length; operationIndex++) {
76742                     writeOperation(operationIndex);
76743                 }
76744                 flushFinalLabel(operations.length);
76745             }
76746             else {
76747                 flushFinalLabel(0);
76748             }
76749             if (clauses) {
76750                 var labelExpression = factory.createPropertyAccessExpression(state, "label");
76751                 var switchStatement = factory.createSwitchStatement(labelExpression, factory.createCaseBlock(clauses));
76752                 return [ts.startOnNewLine(switchStatement)];
76753             }
76754             if (statements) {
76755                 return statements;
76756             }
76757             return [];
76758         }
76759         function flushLabel() {
76760             if (!statements) {
76761                 return;
76762             }
76763             appendLabel(!lastOperationWasAbrupt);
76764             lastOperationWasAbrupt = false;
76765             lastOperationWasCompletion = false;
76766             labelNumber++;
76767         }
76768         function flushFinalLabel(operationIndex) {
76769             if (isFinalLabelReachable(operationIndex)) {
76770                 tryEnterLabel(operationIndex);
76771                 withBlockStack = undefined;
76772                 writeReturn(undefined, undefined);
76773             }
76774             if (statements && clauses) {
76775                 appendLabel(false);
76776             }
76777             updateLabelExpressions();
76778         }
76779         function isFinalLabelReachable(operationIndex) {
76780             if (!lastOperationWasCompletion) {
76781                 return true;
76782             }
76783             if (!labelOffsets || !labelExpressions) {
76784                 return false;
76785             }
76786             for (var label = 0; label < labelOffsets.length; label++) {
76787                 if (labelOffsets[label] === operationIndex && labelExpressions[label]) {
76788                     return true;
76789                 }
76790             }
76791             return false;
76792         }
76793         function appendLabel(markLabelEnd) {
76794             if (!clauses) {
76795                 clauses = [];
76796             }
76797             if (statements) {
76798                 if (withBlockStack) {
76799                     for (var i = withBlockStack.length - 1; i >= 0; i--) {
76800                         var withBlock = withBlockStack[i];
76801                         statements = [factory.createWithStatement(withBlock.expression, factory.createBlock(statements))];
76802                     }
76803                 }
76804                 if (currentExceptionBlock) {
76805                     var startLabel = currentExceptionBlock.startLabel, catchLabel = currentExceptionBlock.catchLabel, finallyLabel = currentExceptionBlock.finallyLabel, endLabel = currentExceptionBlock.endLabel;
76806                     statements.unshift(factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(state, "trys"), "push"), undefined, [
76807                         factory.createArrayLiteralExpression([
76808                             createLabel(startLabel),
76809                             createLabel(catchLabel),
76810                             createLabel(finallyLabel),
76811                             createLabel(endLabel)
76812                         ])
76813                     ])));
76814                     currentExceptionBlock = undefined;
76815                 }
76816                 if (markLabelEnd) {
76817                     statements.push(factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(state, "label"), factory.createNumericLiteral(labelNumber + 1))));
76818                 }
76819             }
76820             clauses.push(factory.createCaseClause(factory.createNumericLiteral(labelNumber), statements || []));
76821             statements = undefined;
76822         }
76823         function tryEnterLabel(operationIndex) {
76824             if (!labelOffsets) {
76825                 return;
76826             }
76827             for (var label = 0; label < labelOffsets.length; label++) {
76828                 if (labelOffsets[label] === operationIndex) {
76829                     flushLabel();
76830                     if (labelNumbers === undefined) {
76831                         labelNumbers = [];
76832                     }
76833                     if (labelNumbers[labelNumber] === undefined) {
76834                         labelNumbers[labelNumber] = [label];
76835                     }
76836                     else {
76837                         labelNumbers[labelNumber].push(label);
76838                     }
76839                 }
76840             }
76841         }
76842         function updateLabelExpressions() {
76843             if (labelExpressions !== undefined && labelNumbers !== undefined) {
76844                 for (var labelNumber_1 = 0; labelNumber_1 < labelNumbers.length; labelNumber_1++) {
76845                     var labels = labelNumbers[labelNumber_1];
76846                     if (labels !== undefined) {
76847                         for (var _i = 0, labels_1 = labels; _i < labels_1.length; _i++) {
76848                             var label = labels_1[_i];
76849                             var expressions = labelExpressions[label];
76850                             if (expressions !== undefined) {
76851                                 for (var _a = 0, expressions_1 = expressions; _a < expressions_1.length; _a++) {
76852                                     var expression = expressions_1[_a];
76853                                     expression.text = String(labelNumber_1);
76854                                 }
76855                             }
76856                         }
76857                     }
76858                 }
76859             }
76860         }
76861         function tryEnterOrLeaveBlock(operationIndex) {
76862             if (blocks) {
76863                 for (; blockIndex < blockActions.length && blockOffsets[blockIndex] <= operationIndex; blockIndex++) {
76864                     var block = blocks[blockIndex];
76865                     var blockAction = blockActions[blockIndex];
76866                     switch (block.kind) {
76867                         case 0:
76868                             if (blockAction === 0) {
76869                                 if (!exceptionBlockStack) {
76870                                     exceptionBlockStack = [];
76871                                 }
76872                                 if (!statements) {
76873                                     statements = [];
76874                                 }
76875                                 exceptionBlockStack.push(currentExceptionBlock);
76876                                 currentExceptionBlock = block;
76877                             }
76878                             else if (blockAction === 1) {
76879                                 currentExceptionBlock = exceptionBlockStack.pop();
76880                             }
76881                             break;
76882                         case 1:
76883                             if (blockAction === 0) {
76884                                 if (!withBlockStack) {
76885                                     withBlockStack = [];
76886                                 }
76887                                 withBlockStack.push(block);
76888                             }
76889                             else if (blockAction === 1) {
76890                                 withBlockStack.pop();
76891                             }
76892                             break;
76893                     }
76894                 }
76895             }
76896         }
76897         function writeOperation(operationIndex) {
76898             tryEnterLabel(operationIndex);
76899             tryEnterOrLeaveBlock(operationIndex);
76900             if (lastOperationWasAbrupt) {
76901                 return;
76902             }
76903             lastOperationWasAbrupt = false;
76904             lastOperationWasCompletion = false;
76905             var opcode = operations[operationIndex];
76906             if (opcode === 0) {
76907                 return;
76908             }
76909             else if (opcode === 10) {
76910                 return writeEndfinally();
76911             }
76912             var args = operationArguments[operationIndex];
76913             if (opcode === 1) {
76914                 return writeStatement(args[0]);
76915             }
76916             var location = operationLocations[operationIndex];
76917             switch (opcode) {
76918                 case 2:
76919                     return writeAssign(args[0], args[1], location);
76920                 case 3:
76921                     return writeBreak(args[0], location);
76922                 case 4:
76923                     return writeBreakWhenTrue(args[0], args[1], location);
76924                 case 5:
76925                     return writeBreakWhenFalse(args[0], args[1], location);
76926                 case 6:
76927                     return writeYield(args[0], location);
76928                 case 7:
76929                     return writeYieldStar(args[0], location);
76930                 case 8:
76931                     return writeReturn(args[0], location);
76932                 case 9:
76933                     return writeThrow(args[0], location);
76934             }
76935         }
76936         function writeStatement(statement) {
76937             if (statement) {
76938                 if (!statements) {
76939                     statements = [statement];
76940                 }
76941                 else {
76942                     statements.push(statement);
76943                 }
76944             }
76945         }
76946         function writeAssign(left, right, operationLocation) {
76947             writeStatement(ts.setTextRange(factory.createExpressionStatement(factory.createAssignment(left, right)), operationLocation));
76948         }
76949         function writeThrow(expression, operationLocation) {
76950             lastOperationWasAbrupt = true;
76951             lastOperationWasCompletion = true;
76952             writeStatement(ts.setTextRange(factory.createThrowStatement(expression), operationLocation));
76953         }
76954         function writeReturn(expression, operationLocation) {
76955             lastOperationWasAbrupt = true;
76956             lastOperationWasCompletion = true;
76957             writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression
76958                 ? [createInstruction(2), expression]
76959                 : [createInstruction(2)])), operationLocation), 384));
76960         }
76961         function writeBreak(label, operationLocation) {
76962             lastOperationWasAbrupt = true;
76963             writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([
76964                 createInstruction(3),
76965                 createLabel(label)
76966             ])), operationLocation), 384));
76967         }
76968         function writeBreakWhenTrue(label, condition, operationLocation) {
76969             writeStatement(ts.setEmitFlags(factory.createIfStatement(condition, ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([
76970                 createInstruction(3),
76971                 createLabel(label)
76972             ])), operationLocation), 384)), 1));
76973         }
76974         function writeBreakWhenFalse(label, condition, operationLocation) {
76975             writeStatement(ts.setEmitFlags(factory.createIfStatement(factory.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([
76976                 createInstruction(3),
76977                 createLabel(label)
76978             ])), operationLocation), 384)), 1));
76979         }
76980         function writeYield(expression, operationLocation) {
76981             lastOperationWasAbrupt = true;
76982             writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression
76983                 ? [createInstruction(4), expression]
76984                 : [createInstruction(4)])), operationLocation), 384));
76985         }
76986         function writeYieldStar(expression, operationLocation) {
76987             lastOperationWasAbrupt = true;
76988             writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([
76989                 createInstruction(5),
76990                 expression
76991             ])), operationLocation), 384));
76992         }
76993         function writeEndfinally() {
76994             lastOperationWasAbrupt = true;
76995             writeStatement(factory.createReturnStatement(factory.createArrayLiteralExpression([
76996                 createInstruction(7)
76997             ])));
76998         }
76999     }
77000     ts.transformGenerators = transformGenerators;
77001 })(ts || (ts = {}));
77002 var ts;
77003 (function (ts) {
77004     function transformModule(context) {
77005         function getTransformModuleDelegate(moduleKind) {
77006             switch (moduleKind) {
77007                 case ts.ModuleKind.AMD: return transformAMDModule;
77008                 case ts.ModuleKind.UMD: return transformUMDModule;
77009                 default: return transformCommonJSModule;
77010             }
77011         }
77012         var factory = context.factory, emitHelpers = context.getEmitHelperFactory, startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
77013         var compilerOptions = context.getCompilerOptions();
77014         var resolver = context.getEmitResolver();
77015         var host = context.getEmitHost();
77016         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
77017         var moduleKind = ts.getEmitModuleKind(compilerOptions);
77018         var previousOnSubstituteNode = context.onSubstituteNode;
77019         var previousOnEmitNode = context.onEmitNode;
77020         context.onSubstituteNode = onSubstituteNode;
77021         context.onEmitNode = onEmitNode;
77022         context.enableSubstitution(78);
77023         context.enableSubstitution(216);
77024         context.enableSubstitution(214);
77025         context.enableSubstitution(215);
77026         context.enableSubstitution(289);
77027         context.enableEmitNotification(297);
77028         var moduleInfoMap = [];
77029         var deferredExports = [];
77030         var currentSourceFile;
77031         var currentModuleInfo;
77032         var noSubstitution;
77033         var needUMDDynamicImportHelper;
77034         return ts.chainBundle(context, transformSourceFile);
77035         function transformSourceFile(node) {
77036             if (node.isDeclarationFile ||
77037                 !(ts.isEffectiveExternalModule(node, compilerOptions) ||
77038                     node.transformFlags & 2097152 ||
77039                     (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) {
77040                 return node;
77041             }
77042             currentSourceFile = node;
77043             currentModuleInfo = ts.collectExternalModuleInfo(context, node, resolver, compilerOptions);
77044             moduleInfoMap[ts.getOriginalNodeId(node)] = currentModuleInfo;
77045             var transformModule = getTransformModuleDelegate(moduleKind);
77046             var updated = transformModule(node);
77047             currentSourceFile = undefined;
77048             currentModuleInfo = undefined;
77049             needUMDDynamicImportHelper = false;
77050             return updated;
77051         }
77052         function shouldEmitUnderscoreUnderscoreESModule() {
77053             if (!currentModuleInfo.exportEquals && ts.isExternalModule(currentSourceFile)) {
77054                 return true;
77055             }
77056             return false;
77057         }
77058         function transformCommonJSModule(node) {
77059             startLexicalEnvironment();
77060             var statements = [];
77061             var ensureUseStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile));
77062             var statementOffset = factory.copyPrologue(node.statements, statements, ensureUseStrict && !ts.isJsonSourceFile(node), sourceElementVisitor);
77063             if (shouldEmitUnderscoreUnderscoreESModule()) {
77064                 ts.append(statements, createUnderscoreUnderscoreESModule());
77065             }
77066             if (ts.length(currentModuleInfo.exportedNames)) {
77067                 var chunkSize = 50;
77068                 for (var i = 0; i < currentModuleInfo.exportedNames.length; i += chunkSize) {
77069                     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())));
77070                 }
77071             }
77072             ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement));
77073             ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset));
77074             addExportEqualsIfNeeded(statements, false);
77075             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
77076             var updated = factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray(statements), node.statements));
77077             ts.addEmitHelpers(updated, context.readEmitHelpers());
77078             return updated;
77079         }
77080         function transformAMDModule(node) {
77081             var define = factory.createIdentifier("define");
77082             var moduleName = ts.tryGetModuleNameFromFile(factory, node, host, compilerOptions);
77083             var jsonSourceFile = ts.isJsonSourceFile(node) && node;
77084             var _a = collectAsynchronousDependencies(node, true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames;
77085             var updated = factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray([
77086                 factory.createExpressionStatement(factory.createCallExpression(define, undefined, __spreadArrays((moduleName ? [moduleName] : []), [
77087                     factory.createArrayLiteralExpression(jsonSourceFile ? ts.emptyArray : __spreadArrays([
77088                         factory.createStringLiteral("require"),
77089                         factory.createStringLiteral("exports")
77090                     ], aliasedModuleNames, unaliasedModuleNames)),
77091                     jsonSourceFile ?
77092                         jsonSourceFile.statements.length ? jsonSourceFile.statements[0].expression : factory.createObjectLiteralExpression() :
77093                         factory.createFunctionExpression(undefined, undefined, undefined, undefined, __spreadArrays([
77094                             factory.createParameterDeclaration(undefined, undefined, undefined, "require"),
77095                             factory.createParameterDeclaration(undefined, undefined, undefined, "exports")
77096                         ], importAliasNames), undefined, transformAsynchronousModuleBody(node))
77097                 ])))
77098             ]), node.statements));
77099             ts.addEmitHelpers(updated, context.readEmitHelpers());
77100             return updated;
77101         }
77102         function transformUMDModule(node) {
77103             var _a = collectAsynchronousDependencies(node, false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames;
77104             var moduleName = ts.tryGetModuleNameFromFile(factory, node, host, compilerOptions);
77105             var umdHeader = factory.createFunctionExpression(undefined, undefined, undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, undefined, "factory")], undefined, ts.setTextRange(factory.createBlock([
77106                 factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("module"), "object"), factory.createTypeCheck(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), "object")), factory.createBlock([
77107                     factory.createVariableStatement(undefined, [
77108                         factory.createVariableDeclaration("v", undefined, undefined, factory.createCallExpression(factory.createIdentifier("factory"), undefined, [
77109                             factory.createIdentifier("require"),
77110                             factory.createIdentifier("exports")
77111                         ]))
77112                     ]),
77113                     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)
77114                 ]), factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("define"), "function"), factory.createPropertyAccessExpression(factory.createIdentifier("define"), "amd")), factory.createBlock([
77115                     factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("define"), undefined, __spreadArrays((moduleName ? [moduleName] : []), [
77116                         factory.createArrayLiteralExpression(__spreadArrays([
77117                             factory.createStringLiteral("require"),
77118                             factory.createStringLiteral("exports")
77119                         ], aliasedModuleNames, unaliasedModuleNames)),
77120                         factory.createIdentifier("factory")
77121                     ])))
77122                 ])))
77123             ], true), undefined));
77124             var updated = factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray([
77125                 factory.createExpressionStatement(factory.createCallExpression(umdHeader, undefined, [
77126                     factory.createFunctionExpression(undefined, undefined, undefined, undefined, __spreadArrays([
77127                         factory.createParameterDeclaration(undefined, undefined, undefined, "require"),
77128                         factory.createParameterDeclaration(undefined, undefined, undefined, "exports")
77129                     ], importAliasNames), undefined, transformAsynchronousModuleBody(node))
77130                 ]))
77131             ]), node.statements));
77132             ts.addEmitHelpers(updated, context.readEmitHelpers());
77133             return updated;
77134         }
77135         function collectAsynchronousDependencies(node, includeNonAmdDependencies) {
77136             var aliasedModuleNames = [];
77137             var unaliasedModuleNames = [];
77138             var importAliasNames = [];
77139             for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) {
77140                 var amdDependency = _a[_i];
77141                 if (amdDependency.name) {
77142                     aliasedModuleNames.push(factory.createStringLiteral(amdDependency.path));
77143                     importAliasNames.push(factory.createParameterDeclaration(undefined, undefined, undefined, amdDependency.name));
77144                 }
77145                 else {
77146                     unaliasedModuleNames.push(factory.createStringLiteral(amdDependency.path));
77147                 }
77148             }
77149             for (var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++) {
77150                 var importNode = _c[_b];
77151                 var externalModuleName = ts.getExternalModuleNameLiteral(factory, importNode, currentSourceFile, host, resolver, compilerOptions);
77152                 var importAliasName = ts.getLocalNameForExternalImport(factory, importNode, currentSourceFile);
77153                 if (externalModuleName) {
77154                     if (includeNonAmdDependencies && importAliasName) {
77155                         ts.setEmitFlags(importAliasName, 4);
77156                         aliasedModuleNames.push(externalModuleName);
77157                         importAliasNames.push(factory.createParameterDeclaration(undefined, undefined, undefined, importAliasName));
77158                     }
77159                     else {
77160                         unaliasedModuleNames.push(externalModuleName);
77161                     }
77162                 }
77163             }
77164             return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames };
77165         }
77166         function getAMDImportExpressionForImport(node) {
77167             if (ts.isImportEqualsDeclaration(node) || ts.isExportDeclaration(node) || !ts.getExternalModuleNameLiteral(factory, node, currentSourceFile, host, resolver, compilerOptions)) {
77168                 return undefined;
77169             }
77170             var name = ts.getLocalNameForExternalImport(factory, node, currentSourceFile);
77171             var expr = getHelperExpressionForImport(node, name);
77172             if (expr === name) {
77173                 return undefined;
77174             }
77175             return factory.createExpressionStatement(factory.createAssignment(name, expr));
77176         }
77177         function transformAsynchronousModuleBody(node) {
77178             startLexicalEnvironment();
77179             var statements = [];
77180             var statementOffset = factory.copyPrologue(node.statements, statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor);
77181             if (shouldEmitUnderscoreUnderscoreESModule()) {
77182                 ts.append(statements, createUnderscoreUnderscoreESModule());
77183             }
77184             if (ts.length(currentModuleInfo.exportedNames)) {
77185                 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())));
77186             }
77187             ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement));
77188             if (moduleKind === ts.ModuleKind.AMD) {
77189                 ts.addRange(statements, ts.mapDefined(currentModuleInfo.externalImports, getAMDImportExpressionForImport));
77190             }
77191             ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset));
77192             addExportEqualsIfNeeded(statements, true);
77193             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
77194             var body = factory.createBlock(statements, true);
77195             if (needUMDDynamicImportHelper) {
77196                 ts.addEmitHelper(body, dynamicImportUMDHelper);
77197             }
77198             return body;
77199         }
77200         function addExportEqualsIfNeeded(statements, emitAsReturn) {
77201             if (currentModuleInfo.exportEquals) {
77202                 var expressionResult = ts.visitNode(currentModuleInfo.exportEquals.expression, moduleExpressionElementVisitor);
77203                 if (expressionResult) {
77204                     if (emitAsReturn) {
77205                         var statement = factory.createReturnStatement(expressionResult);
77206                         ts.setTextRange(statement, currentModuleInfo.exportEquals);
77207                         ts.setEmitFlags(statement, 384 | 1536);
77208                         statements.push(statement);
77209                     }
77210                     else {
77211                         var statement = factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), expressionResult));
77212                         ts.setTextRange(statement, currentModuleInfo.exportEquals);
77213                         ts.setEmitFlags(statement, 1536);
77214                         statements.push(statement);
77215                     }
77216                 }
77217             }
77218         }
77219         function sourceElementVisitor(node) {
77220             switch (node.kind) {
77221                 case 261:
77222                     return visitImportDeclaration(node);
77223                 case 260:
77224                     return visitImportEqualsDeclaration(node);
77225                 case 267:
77226                     return visitExportDeclaration(node);
77227                 case 266:
77228                     return visitExportAssignment(node);
77229                 case 232:
77230                     return visitVariableStatement(node);
77231                 case 251:
77232                     return visitFunctionDeclaration(node);
77233                 case 252:
77234                     return visitClassDeclaration(node);
77235                 case 338:
77236                     return visitMergeDeclarationMarker(node);
77237                 case 339:
77238                     return visitEndOfDeclarationMarker(node);
77239                 default:
77240                     return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
77241             }
77242         }
77243         function moduleExpressionElementVisitor(node) {
77244             if (!(node.transformFlags & 2097152) && !(node.transformFlags & 1024)) {
77245                 return node;
77246             }
77247             if (ts.isImportCall(node)) {
77248                 return visitImportCallExpression(node);
77249             }
77250             else if (ts.isDestructuringAssignment(node)) {
77251                 return visitDestructuringAssignment(node);
77252             }
77253             else {
77254                 return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
77255             }
77256         }
77257         function destructuringNeedsFlattening(node) {
77258             if (ts.isObjectLiteralExpression(node)) {
77259                 for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
77260                     var elem = _a[_i];
77261                     switch (elem.kind) {
77262                         case 288:
77263                             if (destructuringNeedsFlattening(elem.initializer)) {
77264                                 return true;
77265                             }
77266                             break;
77267                         case 289:
77268                             if (destructuringNeedsFlattening(elem.name)) {
77269                                 return true;
77270                             }
77271                             break;
77272                         case 290:
77273                             if (destructuringNeedsFlattening(elem.expression)) {
77274                                 return true;
77275                             }
77276                             break;
77277                         case 165:
77278                         case 167:
77279                         case 168:
77280                             return false;
77281                         default: ts.Debug.assertNever(elem, "Unhandled object member kind");
77282                     }
77283                 }
77284             }
77285             else if (ts.isArrayLiteralExpression(node)) {
77286                 for (var _b = 0, _c = node.elements; _b < _c.length; _b++) {
77287                     var elem = _c[_b];
77288                     if (ts.isSpreadElement(elem)) {
77289                         if (destructuringNeedsFlattening(elem.expression)) {
77290                             return true;
77291                         }
77292                     }
77293                     else if (destructuringNeedsFlattening(elem)) {
77294                         return true;
77295                     }
77296                 }
77297             }
77298             else if (ts.isIdentifier(node)) {
77299                 return ts.length(getExports(node)) > (ts.isExportName(node) ? 1 : 0);
77300             }
77301             return false;
77302         }
77303         function visitDestructuringAssignment(node) {
77304             if (destructuringNeedsFlattening(node.left)) {
77305                 return ts.flattenDestructuringAssignment(node, moduleExpressionElementVisitor, context, 0, false, createAllExportExpressions);
77306             }
77307             return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
77308         }
77309         function visitImportCallExpression(node) {
77310             var argument = ts.visitNode(ts.firstOrUndefined(node.arguments), moduleExpressionElementVisitor);
77311             var containsLexicalThis = !!(node.transformFlags & 4096);
77312             switch (compilerOptions.module) {
77313                 case ts.ModuleKind.AMD:
77314                     return createImportCallExpressionAMD(argument, containsLexicalThis);
77315                 case ts.ModuleKind.UMD:
77316                     return createImportCallExpressionUMD(argument !== null && argument !== void 0 ? argument : factory.createVoidZero(), containsLexicalThis);
77317                 case ts.ModuleKind.CommonJS:
77318                 default:
77319                     return createImportCallExpressionCommonJS(argument, containsLexicalThis);
77320             }
77321         }
77322         function createImportCallExpressionUMD(arg, containsLexicalThis) {
77323             needUMDDynamicImportHelper = true;
77324             if (ts.isSimpleCopiableExpression(arg)) {
77325                 var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536);
77326                 return factory.createConditionalExpression(factory.createIdentifier("__syncRequire"), undefined, createImportCallExpressionCommonJS(arg, containsLexicalThis), undefined, createImportCallExpressionAMD(argClone, containsLexicalThis));
77327             }
77328             else {
77329                 var temp = factory.createTempVariable(hoistVariableDeclaration);
77330                 return factory.createComma(factory.createAssignment(temp, arg), factory.createConditionalExpression(factory.createIdentifier("__syncRequire"), undefined, createImportCallExpressionCommonJS(temp, containsLexicalThis), undefined, createImportCallExpressionAMD(temp, containsLexicalThis)));
77331             }
77332         }
77333         function createImportCallExpressionAMD(arg, containsLexicalThis) {
77334             var resolve = factory.createUniqueName("resolve");
77335             var reject = factory.createUniqueName("reject");
77336             var parameters = [
77337                 factory.createParameterDeclaration(undefined, undefined, undefined, resolve),
77338                 factory.createParameterDeclaration(undefined, undefined, undefined, reject)
77339             ];
77340             var body = factory.createBlock([
77341                 factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("require"), undefined, [factory.createArrayLiteralExpression([arg || factory.createOmittedExpression()]), resolve, reject]))
77342             ]);
77343             var func;
77344             if (languageVersion >= 2) {
77345                 func = factory.createArrowFunction(undefined, undefined, parameters, undefined, undefined, body);
77346             }
77347             else {
77348                 func = factory.createFunctionExpression(undefined, undefined, undefined, undefined, parameters, undefined, body);
77349                 if (containsLexicalThis) {
77350                     ts.setEmitFlags(func, 8);
77351                 }
77352             }
77353             var promise = factory.createNewExpression(factory.createIdentifier("Promise"), undefined, [func]);
77354             if (compilerOptions.esModuleInterop) {
77355                 return factory.createCallExpression(factory.createPropertyAccessExpression(promise, factory.createIdentifier("then")), undefined, [emitHelpers().createImportStarCallbackHelper()]);
77356             }
77357             return promise;
77358         }
77359         function createImportCallExpressionCommonJS(arg, containsLexicalThis) {
77360             var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"), undefined, []);
77361             var requireCall = factory.createCallExpression(factory.createIdentifier("require"), undefined, arg ? [arg] : []);
77362             if (compilerOptions.esModuleInterop) {
77363                 requireCall = emitHelpers().createImportStarHelper(requireCall);
77364             }
77365             var func;
77366             if (languageVersion >= 2) {
77367                 func = factory.createArrowFunction(undefined, undefined, [], undefined, undefined, requireCall);
77368             }
77369             else {
77370                 func = factory.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, factory.createBlock([factory.createReturnStatement(requireCall)]));
77371                 if (containsLexicalThis) {
77372                     ts.setEmitFlags(func, 8);
77373                 }
77374             }
77375             return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), undefined, [func]);
77376         }
77377         function getHelperExpressionForExport(node, innerExpr) {
77378             if (!compilerOptions.esModuleInterop || ts.getEmitFlags(node) & 67108864) {
77379                 return innerExpr;
77380             }
77381             if (ts.getExportNeedsImportStarHelper(node)) {
77382                 return emitHelpers().createImportStarHelper(innerExpr);
77383             }
77384             return innerExpr;
77385         }
77386         function getHelperExpressionForImport(node, innerExpr) {
77387             if (!compilerOptions.esModuleInterop || ts.getEmitFlags(node) & 67108864) {
77388                 return innerExpr;
77389             }
77390             if (ts.getImportNeedsImportStarHelper(node)) {
77391                 return emitHelpers().createImportStarHelper(innerExpr);
77392             }
77393             if (ts.getImportNeedsImportDefaultHelper(node)) {
77394                 return emitHelpers().createImportDefaultHelper(innerExpr);
77395             }
77396             return innerExpr;
77397         }
77398         function visitImportDeclaration(node) {
77399             var statements;
77400             var namespaceDeclaration = ts.getNamespaceDeclarationNode(node);
77401             if (moduleKind !== ts.ModuleKind.AMD) {
77402                 if (!node.importClause) {
77403                     return ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createRequireCall(node)), node), node);
77404                 }
77405                 else {
77406                     var variables = [];
77407                     if (namespaceDeclaration && !ts.isDefaultImport(node)) {
77408                         variables.push(factory.createVariableDeclaration(factory.cloneNode(namespaceDeclaration.name), undefined, undefined, getHelperExpressionForImport(node, createRequireCall(node))));
77409                     }
77410                     else {
77411                         variables.push(factory.createVariableDeclaration(factory.getGeneratedNameForNode(node), undefined, undefined, getHelperExpressionForImport(node, createRequireCall(node))));
77412                         if (namespaceDeclaration && ts.isDefaultImport(node)) {
77413                             variables.push(factory.createVariableDeclaration(factory.cloneNode(namespaceDeclaration.name), undefined, undefined, factory.getGeneratedNameForNode(node)));
77414                         }
77415                     }
77416                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement(undefined, factory.createVariableDeclarationList(variables, languageVersion >= 2 ? 2 : 0)), node), node));
77417                 }
77418             }
77419             else if (namespaceDeclaration && ts.isDefaultImport(node)) {
77420                 statements = ts.append(statements, factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
77421                     ts.setOriginalNode(ts.setTextRange(factory.createVariableDeclaration(factory.cloneNode(namespaceDeclaration.name), undefined, undefined, factory.getGeneratedNameForNode(node)), node), node)
77422                 ], languageVersion >= 2 ? 2 : 0)));
77423             }
77424             if (hasAssociatedEndOfDeclarationMarker(node)) {
77425                 var id = ts.getOriginalNodeId(node);
77426                 deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node);
77427             }
77428             else {
77429                 statements = appendExportsOfImportDeclaration(statements, node);
77430             }
77431             return ts.singleOrMany(statements);
77432         }
77433         function createRequireCall(importNode) {
77434             var moduleName = ts.getExternalModuleNameLiteral(factory, importNode, currentSourceFile, host, resolver, compilerOptions);
77435             var args = [];
77436             if (moduleName) {
77437                 args.push(moduleName);
77438             }
77439             return factory.createCallExpression(factory.createIdentifier("require"), undefined, args);
77440         }
77441         function visitImportEqualsDeclaration(node) {
77442             ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer.");
77443             var statements;
77444             if (moduleKind !== ts.ModuleKind.AMD) {
77445                 if (ts.hasSyntacticModifier(node, 1)) {
77446                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node), node));
77447                 }
77448                 else {
77449                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
77450                         factory.createVariableDeclaration(factory.cloneNode(node.name), undefined, undefined, createRequireCall(node))
77451                     ], languageVersion >= 2 ? 2 : 0)), node), node));
77452                 }
77453             }
77454             else {
77455                 if (ts.hasSyntacticModifier(node, 1)) {
77456                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(node), factory.getLocalName(node))), node), node));
77457                 }
77458             }
77459             if (hasAssociatedEndOfDeclarationMarker(node)) {
77460                 var id = ts.getOriginalNodeId(node);
77461                 deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node);
77462             }
77463             else {
77464                 statements = appendExportsOfImportEqualsDeclaration(statements, node);
77465             }
77466             return ts.singleOrMany(statements);
77467         }
77468         function visitExportDeclaration(node) {
77469             if (!node.moduleSpecifier) {
77470                 return undefined;
77471             }
77472             var generatedName = factory.getGeneratedNameForNode(node);
77473             if (node.exportClause && ts.isNamedExports(node.exportClause)) {
77474                 var statements = [];
77475                 if (moduleKind !== ts.ModuleKind.AMD) {
77476                     statements.push(ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
77477                         factory.createVariableDeclaration(generatedName, undefined, undefined, createRequireCall(node))
77478                     ])), node), node));
77479                 }
77480                 for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) {
77481                     var specifier = _a[_i];
77482                     if (languageVersion === 0) {
77483                         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));
77484                     }
77485                     else {
77486                         var exportNeedsImportDefault = !!compilerOptions.esModuleInterop &&
77487                             !(ts.getEmitFlags(node) & 67108864) &&
77488                             ts.idText(specifier.propertyName || specifier.name) === "default";
77489                         var exportedValue = factory.createPropertyAccessExpression(exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, specifier.propertyName || specifier.name);
77490                         statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(specifier), exportedValue, undefined, true)), specifier), specifier));
77491                     }
77492                 }
77493                 return ts.singleOrMany(statements);
77494             }
77495             else if (node.exportClause) {
77496                 var statements = [];
77497                 statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.cloneNode(node.exportClause.name), getHelperExpressionForExport(node, moduleKind !== ts.ModuleKind.AMD ?
77498                     createRequireCall(node) :
77499                     ts.isExportNamespaceAsDefaultDeclaration(node) ? generatedName :
77500                         factory.createIdentifier(ts.idText(node.exportClause.name))))), node), node));
77501                 return ts.singleOrMany(statements);
77502             }
77503             else {
77504                 return ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(emitHelpers().createExportStarHelper(moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node), node);
77505             }
77506         }
77507         function visitExportAssignment(node) {
77508             if (node.isExportEquals) {
77509                 return undefined;
77510             }
77511             var statements;
77512             var original = node.original;
77513             if (original && hasAssociatedEndOfDeclarationMarker(original)) {
77514                 var id = ts.getOriginalNodeId(node);
77515                 deferredExports[id] = appendExportStatement(deferredExports[id], factory.createIdentifier("default"), ts.visitNode(node.expression, moduleExpressionElementVisitor), node, true);
77516             }
77517             else {
77518                 statements = appendExportStatement(statements, factory.createIdentifier("default"), ts.visitNode(node.expression, moduleExpressionElementVisitor), node, true);
77519             }
77520             return ts.singleOrMany(statements);
77521         }
77522         function visitFunctionDeclaration(node) {
77523             var statements;
77524             if (ts.hasSyntacticModifier(node, 1)) {
77525                 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));
77526             }
77527             else {
77528                 statements = ts.append(statements, ts.visitEachChild(node, moduleExpressionElementVisitor, context));
77529             }
77530             if (hasAssociatedEndOfDeclarationMarker(node)) {
77531                 var id = ts.getOriginalNodeId(node);
77532                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
77533             }
77534             else {
77535                 statements = appendExportsOfHoistedDeclaration(statements, node);
77536             }
77537             return ts.singleOrMany(statements);
77538         }
77539         function visitClassDeclaration(node) {
77540             var statements;
77541             if (ts.hasSyntacticModifier(node, 1)) {
77542                 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));
77543             }
77544             else {
77545                 statements = ts.append(statements, ts.visitEachChild(node, moduleExpressionElementVisitor, context));
77546             }
77547             if (hasAssociatedEndOfDeclarationMarker(node)) {
77548                 var id = ts.getOriginalNodeId(node);
77549                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
77550             }
77551             else {
77552                 statements = appendExportsOfHoistedDeclaration(statements, node);
77553             }
77554             return ts.singleOrMany(statements);
77555         }
77556         function visitVariableStatement(node) {
77557             var statements;
77558             var variables;
77559             var expressions;
77560             if (ts.hasSyntacticModifier(node, 1)) {
77561                 var modifiers = void 0;
77562                 var removeCommentsOnExpressions = false;
77563                 for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
77564                     var variable = _a[_i];
77565                     if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) {
77566                         if (!modifiers) {
77567                             modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier);
77568                         }
77569                         variables = ts.append(variables, variable);
77570                     }
77571                     else if (variable.initializer) {
77572                         if (!ts.isBindingPattern(variable.name) && (ts.isArrowFunction(variable.initializer) || ts.isFunctionExpression(variable.initializer) || ts.isClassExpression(variable.initializer))) {
77573                             var expression = factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), variable.name), variable.name), factory.createIdentifier(ts.getTextOfIdentifierOrLiteral(variable.name)));
77574                             var updatedVariable = factory.createVariableDeclaration(variable.name, variable.exclamationToken, variable.type, ts.visitNode(variable.initializer, moduleExpressionElementVisitor));
77575                             variables = ts.append(variables, updatedVariable);
77576                             expressions = ts.append(expressions, expression);
77577                             removeCommentsOnExpressions = true;
77578                         }
77579                         else {
77580                             expressions = ts.append(expressions, transformInitializedVariable(variable));
77581                         }
77582                     }
77583                 }
77584                 if (variables) {
77585                     statements = ts.append(statements, factory.updateVariableStatement(node, modifiers, factory.updateVariableDeclarationList(node.declarationList, variables)));
77586                 }
77587                 if (expressions) {
77588                     var statement = ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(factory.inlineExpressions(expressions)), node), node);
77589                     if (removeCommentsOnExpressions) {
77590                         ts.removeAllComments(statement);
77591                     }
77592                     statements = ts.append(statements, statement);
77593                 }
77594             }
77595             else {
77596                 statements = ts.append(statements, ts.visitEachChild(node, moduleExpressionElementVisitor, context));
77597             }
77598             if (hasAssociatedEndOfDeclarationMarker(node)) {
77599                 var id = ts.getOriginalNodeId(node);
77600                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node);
77601             }
77602             else {
77603                 statements = appendExportsOfVariableStatement(statements, node);
77604             }
77605             return ts.singleOrMany(statements);
77606         }
77607         function createAllExportExpressions(name, value, location) {
77608             var exportedNames = getExports(name);
77609             if (exportedNames) {
77610                 var expression = ts.isExportName(name) ? value : factory.createAssignment(name, value);
77611                 for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) {
77612                     var exportName = exportedNames_1[_i];
77613                     ts.setEmitFlags(expression, 4);
77614                     expression = createExportExpression(exportName, expression, location);
77615                 }
77616                 return expression;
77617             }
77618             return factory.createAssignment(name, value);
77619         }
77620         function transformInitializedVariable(node) {
77621             if (ts.isBindingPattern(node.name)) {
77622                 return ts.flattenDestructuringAssignment(ts.visitNode(node, moduleExpressionElementVisitor), undefined, context, 0, false, createAllExportExpressions);
77623             }
77624             else {
77625                 return factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), node.name), node.name), node.initializer ? ts.visitNode(node.initializer, moduleExpressionElementVisitor) : factory.createVoidZero());
77626             }
77627         }
77628         function visitMergeDeclarationMarker(node) {
77629             if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 232) {
77630                 var id = ts.getOriginalNodeId(node);
77631                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original);
77632             }
77633             return node;
77634         }
77635         function hasAssociatedEndOfDeclarationMarker(node) {
77636             return (ts.getEmitFlags(node) & 4194304) !== 0;
77637         }
77638         function visitEndOfDeclarationMarker(node) {
77639             var id = ts.getOriginalNodeId(node);
77640             var statements = deferredExports[id];
77641             if (statements) {
77642                 delete deferredExports[id];
77643                 return ts.append(statements, node);
77644             }
77645             return node;
77646         }
77647         function appendExportsOfImportDeclaration(statements, decl) {
77648             if (currentModuleInfo.exportEquals) {
77649                 return statements;
77650             }
77651             var importClause = decl.importClause;
77652             if (!importClause) {
77653                 return statements;
77654             }
77655             if (importClause.name) {
77656                 statements = appendExportsOfDeclaration(statements, importClause);
77657             }
77658             var namedBindings = importClause.namedBindings;
77659             if (namedBindings) {
77660                 switch (namedBindings.kind) {
77661                     case 263:
77662                         statements = appendExportsOfDeclaration(statements, namedBindings);
77663                         break;
77664                     case 264:
77665                         for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) {
77666                             var importBinding = _a[_i];
77667                             statements = appendExportsOfDeclaration(statements, importBinding, true);
77668                         }
77669                         break;
77670                 }
77671             }
77672             return statements;
77673         }
77674         function appendExportsOfImportEqualsDeclaration(statements, decl) {
77675             if (currentModuleInfo.exportEquals) {
77676                 return statements;
77677             }
77678             return appendExportsOfDeclaration(statements, decl);
77679         }
77680         function appendExportsOfVariableStatement(statements, node) {
77681             if (currentModuleInfo.exportEquals) {
77682                 return statements;
77683             }
77684             for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
77685                 var decl = _a[_i];
77686                 statements = appendExportsOfBindingElement(statements, decl);
77687             }
77688             return statements;
77689         }
77690         function appendExportsOfBindingElement(statements, decl) {
77691             if (currentModuleInfo.exportEquals) {
77692                 return statements;
77693             }
77694             if (ts.isBindingPattern(decl.name)) {
77695                 for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) {
77696                     var element = _a[_i];
77697                     if (!ts.isOmittedExpression(element)) {
77698                         statements = appendExportsOfBindingElement(statements, element);
77699                     }
77700                 }
77701             }
77702             else if (!ts.isGeneratedIdentifier(decl.name)) {
77703                 statements = appendExportsOfDeclaration(statements, decl);
77704             }
77705             return statements;
77706         }
77707         function appendExportsOfHoistedDeclaration(statements, decl) {
77708             if (currentModuleInfo.exportEquals) {
77709                 return statements;
77710             }
77711             if (ts.hasSyntacticModifier(decl, 1)) {
77712                 var exportName = ts.hasSyntacticModifier(decl, 512) ? factory.createIdentifier("default") : factory.getDeclarationName(decl);
77713                 statements = appendExportStatement(statements, exportName, factory.getLocalName(decl), decl);
77714             }
77715             if (decl.name) {
77716                 statements = appendExportsOfDeclaration(statements, decl);
77717             }
77718             return statements;
77719         }
77720         function appendExportsOfDeclaration(statements, decl, liveBinding) {
77721             var name = factory.getDeclarationName(decl);
77722             var exportSpecifiers = currentModuleInfo.exportSpecifiers.get(ts.idText(name));
77723             if (exportSpecifiers) {
77724                 for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) {
77725                     var exportSpecifier = exportSpecifiers_1[_i];
77726                     statements = appendExportStatement(statements, exportSpecifier.name, name, exportSpecifier.name, undefined, liveBinding);
77727                 }
77728             }
77729             return statements;
77730         }
77731         function appendExportStatement(statements, exportName, expression, location, allowComments, liveBinding) {
77732             statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments, liveBinding));
77733             return statements;
77734         }
77735         function createUnderscoreUnderscoreESModule() {
77736             var statement;
77737             if (languageVersion === 0) {
77738                 statement = factory.createExpressionStatement(createExportExpression(factory.createIdentifier("__esModule"), factory.createTrue()));
77739             }
77740             else {
77741                 statement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), undefined, [
77742                     factory.createIdentifier("exports"),
77743                     factory.createStringLiteral("__esModule"),
77744                     factory.createObjectLiteralExpression([
77745                         factory.createPropertyAssignment("value", factory.createTrue())
77746                     ])
77747                 ]));
77748             }
77749             ts.setEmitFlags(statement, 1048576);
77750             return statement;
77751         }
77752         function createExportStatement(name, value, location, allowComments, liveBinding) {
77753             var statement = ts.setTextRange(factory.createExpressionStatement(createExportExpression(name, value, undefined, liveBinding)), location);
77754             ts.startOnNewLine(statement);
77755             if (!allowComments) {
77756                 ts.setEmitFlags(statement, 1536);
77757             }
77758             return statement;
77759         }
77760         function createExportExpression(name, value, location, liveBinding) {
77761             return ts.setTextRange(liveBinding && languageVersion !== 0 ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), undefined, [
77762                 factory.createIdentifier("exports"),
77763                 factory.createStringLiteralFromNode(name),
77764                 factory.createObjectLiteralExpression([
77765                     factory.createPropertyAssignment("enumerable", factory.createTrue()),
77766                     factory.createPropertyAssignment("get", factory.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, factory.createBlock([factory.createReturnStatement(value)])))
77767                 ])
77768             ]) : factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(name)), value), location);
77769         }
77770         function modifierVisitor(node) {
77771             switch (node.kind) {
77772                 case 92:
77773                 case 87:
77774                     return undefined;
77775             }
77776             return node;
77777         }
77778         function onEmitNode(hint, node, emitCallback) {
77779             if (node.kind === 297) {
77780                 currentSourceFile = node;
77781                 currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)];
77782                 noSubstitution = [];
77783                 previousOnEmitNode(hint, node, emitCallback);
77784                 currentSourceFile = undefined;
77785                 currentModuleInfo = undefined;
77786                 noSubstitution = undefined;
77787             }
77788             else {
77789                 previousOnEmitNode(hint, node, emitCallback);
77790             }
77791         }
77792         function onSubstituteNode(hint, node) {
77793             node = previousOnSubstituteNode(hint, node);
77794             if (node.id && noSubstitution[node.id]) {
77795                 return node;
77796             }
77797             if (hint === 1) {
77798                 return substituteExpression(node);
77799             }
77800             else if (ts.isShorthandPropertyAssignment(node)) {
77801                 return substituteShorthandPropertyAssignment(node);
77802             }
77803             return node;
77804         }
77805         function substituteShorthandPropertyAssignment(node) {
77806             var name = node.name;
77807             var exportedOrImportedName = substituteExpressionIdentifier(name);
77808             if (exportedOrImportedName !== name) {
77809                 if (node.objectAssignmentInitializer) {
77810                     var initializer = factory.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer);
77811                     return ts.setTextRange(factory.createPropertyAssignment(name, initializer), node);
77812                 }
77813                 return ts.setTextRange(factory.createPropertyAssignment(name, exportedOrImportedName), node);
77814             }
77815             return node;
77816         }
77817         function substituteExpression(node) {
77818             switch (node.kind) {
77819                 case 78:
77820                     return substituteExpressionIdentifier(node);
77821                 case 216:
77822                     return substituteBinaryExpression(node);
77823                 case 215:
77824                 case 214:
77825                     return substituteUnaryExpression(node);
77826             }
77827             return node;
77828         }
77829         function substituteExpressionIdentifier(node) {
77830             if (ts.getEmitFlags(node) & 4096) {
77831                 var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile);
77832                 if (externalHelpersModuleName) {
77833                     return factory.createPropertyAccessExpression(externalHelpersModuleName, node);
77834                 }
77835                 return node;
77836             }
77837             if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64)) && !ts.isLocalName(node)) {
77838                 var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node));
77839                 if (exportContainer && exportContainer.kind === 297) {
77840                     return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), node);
77841                 }
77842                 var importDeclaration = resolver.getReferencedImportDeclaration(node);
77843                 if (importDeclaration) {
77844                     if (ts.isImportClause(importDeclaration)) {
77845                         return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(importDeclaration.parent), factory.createIdentifier("default")), node);
77846                     }
77847                     else if (ts.isImportSpecifier(importDeclaration)) {
77848                         var name = importDeclaration.propertyName || importDeclaration.name;
77849                         return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(importDeclaration.parent.parent.parent), factory.cloneNode(name)), node);
77850                     }
77851                 }
77852             }
77853             return node;
77854         }
77855         function substituteBinaryExpression(node) {
77856             if (ts.isAssignmentOperator(node.operatorToken.kind)
77857                 && ts.isIdentifier(node.left)
77858                 && !ts.isGeneratedIdentifier(node.left)
77859                 && !ts.isLocalName(node.left)
77860                 && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) {
77861                 var exportedNames = getExports(node.left);
77862                 if (exportedNames) {
77863                     var expression = node;
77864                     for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) {
77865                         var exportName = exportedNames_2[_i];
77866                         noSubstitution[ts.getNodeId(expression)] = true;
77867                         expression = createExportExpression(exportName, expression, node);
77868                     }
77869                     return expression;
77870                 }
77871             }
77872             return node;
77873         }
77874         function substituteUnaryExpression(node) {
77875             if ((node.operator === 45 || node.operator === 46)
77876                 && ts.isIdentifier(node.operand)
77877                 && !ts.isGeneratedIdentifier(node.operand)
77878                 && !ts.isLocalName(node.operand)
77879                 && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) {
77880                 var exportedNames = getExports(node.operand);
77881                 if (exportedNames) {
77882                     var expression = node.kind === 215
77883                         ? ts.setTextRange(factory.createBinaryExpression(node.operand, factory.createToken(node.operator === 45 ? 63 : 64), factory.createNumericLiteral(1)), node)
77884                         : node;
77885                     for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) {
77886                         var exportName = exportedNames_3[_i];
77887                         noSubstitution[ts.getNodeId(expression)] = true;
77888                         expression = createExportExpression(exportName, expression);
77889                     }
77890                     return expression;
77891                 }
77892             }
77893             return node;
77894         }
77895         function getExports(name) {
77896             if (!ts.isGeneratedIdentifier(name)) {
77897                 var valueDeclaration = resolver.getReferencedImportDeclaration(name)
77898                     || resolver.getReferencedValueDeclaration(name);
77899                 if (valueDeclaration) {
77900                     return currentModuleInfo
77901                         && currentModuleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)];
77902                 }
77903             }
77904         }
77905     }
77906     ts.transformModule = transformModule;
77907     var dynamicImportUMDHelper = {
77908         name: "typescript:dynamicimport-sync-require",
77909         scoped: true,
77910         text: "\n            var __syncRequire = typeof module === \"object\" && typeof module.exports === \"object\";"
77911     };
77912 })(ts || (ts = {}));
77913 var ts;
77914 (function (ts) {
77915     function transformSystemModule(context) {
77916         var factory = context.factory, startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
77917         var compilerOptions = context.getCompilerOptions();
77918         var resolver = context.getEmitResolver();
77919         var host = context.getEmitHost();
77920         var previousOnSubstituteNode = context.onSubstituteNode;
77921         var previousOnEmitNode = context.onEmitNode;
77922         context.onSubstituteNode = onSubstituteNode;
77923         context.onEmitNode = onEmitNode;
77924         context.enableSubstitution(78);
77925         context.enableSubstitution(289);
77926         context.enableSubstitution(216);
77927         context.enableSubstitution(214);
77928         context.enableSubstitution(215);
77929         context.enableSubstitution(226);
77930         context.enableEmitNotification(297);
77931         var moduleInfoMap = [];
77932         var deferredExports = [];
77933         var exportFunctionsMap = [];
77934         var noSubstitutionMap = [];
77935         var contextObjectMap = [];
77936         var currentSourceFile;
77937         var moduleInfo;
77938         var exportFunction;
77939         var contextObject;
77940         var hoistedStatements;
77941         var enclosingBlockScopedContainer;
77942         var noSubstitution;
77943         return ts.chainBundle(context, transformSourceFile);
77944         function transformSourceFile(node) {
77945             if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 2097152)) {
77946                 return node;
77947             }
77948             var id = ts.getOriginalNodeId(node);
77949             currentSourceFile = node;
77950             enclosingBlockScopedContainer = node;
77951             moduleInfo = moduleInfoMap[id] = ts.collectExternalModuleInfo(context, node, resolver, compilerOptions);
77952             exportFunction = factory.createUniqueName("exports");
77953             exportFunctionsMap[id] = exportFunction;
77954             contextObject = contextObjectMap[id] = factory.createUniqueName("context");
77955             var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports);
77956             var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups);
77957             var moduleBodyFunction = factory.createFunctionExpression(undefined, undefined, undefined, undefined, [
77958                 factory.createParameterDeclaration(undefined, undefined, undefined, exportFunction),
77959                 factory.createParameterDeclaration(undefined, undefined, undefined, contextObject)
77960             ], undefined, moduleBodyBlock);
77961             var moduleName = ts.tryGetModuleNameFromFile(factory, node, host, compilerOptions);
77962             var dependencies = factory.createArrayLiteralExpression(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; }));
77963             var updated = ts.setEmitFlags(factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray([
77964                 factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("System"), "register"), undefined, moduleName
77965                     ? [moduleName, dependencies, moduleBodyFunction]
77966                     : [dependencies, moduleBodyFunction]))
77967             ]), node.statements)), 1024);
77968             if (!ts.outFile(compilerOptions)) {
77969                 ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; });
77970             }
77971             if (noSubstitution) {
77972                 noSubstitutionMap[id] = noSubstitution;
77973                 noSubstitution = undefined;
77974             }
77975             currentSourceFile = undefined;
77976             moduleInfo = undefined;
77977             exportFunction = undefined;
77978             contextObject = undefined;
77979             hoistedStatements = undefined;
77980             enclosingBlockScopedContainer = undefined;
77981             return updated;
77982         }
77983         function collectDependencyGroups(externalImports) {
77984             var groupIndices = new ts.Map();
77985             var dependencyGroups = [];
77986             for (var _i = 0, externalImports_1 = externalImports; _i < externalImports_1.length; _i++) {
77987                 var externalImport = externalImports_1[_i];
77988                 var externalModuleName = ts.getExternalModuleNameLiteral(factory, externalImport, currentSourceFile, host, resolver, compilerOptions);
77989                 if (externalModuleName) {
77990                     var text = externalModuleName.text;
77991                     var groupIndex = groupIndices.get(text);
77992                     if (groupIndex !== undefined) {
77993                         dependencyGroups[groupIndex].externalImports.push(externalImport);
77994                     }
77995                     else {
77996                         groupIndices.set(text, dependencyGroups.length);
77997                         dependencyGroups.push({
77998                             name: externalModuleName,
77999                             externalImports: [externalImport]
78000                         });
78001                     }
78002                 }
78003             }
78004             return dependencyGroups;
78005         }
78006         function createSystemModuleBody(node, dependencyGroups) {
78007             var statements = [];
78008             startLexicalEnvironment();
78009             var ensureUseStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile));
78010             var statementOffset = factory.copyPrologue(node.statements, statements, ensureUseStrict, sourceElementVisitor);
78011             statements.push(factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
78012                 factory.createVariableDeclaration("__moduleName", undefined, undefined, factory.createLogicalAnd(contextObject, factory.createPropertyAccessExpression(contextObject, "id")))
78013             ])));
78014             ts.visitNode(moduleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement);
78015             var executeStatements = ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset);
78016             ts.addRange(statements, hoistedStatements);
78017             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
78018             var exportStarFunction = addExportStarIfNeeded(statements);
78019             var modifiers = node.transformFlags & 524288 ?
78020                 factory.createModifiersFromModifierFlags(256) :
78021                 undefined;
78022             var moduleObject = factory.createObjectLiteralExpression([
78023                 factory.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)),
78024                 factory.createPropertyAssignment("execute", factory.createFunctionExpression(modifiers, undefined, undefined, undefined, [], undefined, factory.createBlock(executeStatements, true)))
78025             ], true);
78026             statements.push(factory.createReturnStatement(moduleObject));
78027             return factory.createBlock(statements, true);
78028         }
78029         function addExportStarIfNeeded(statements) {
78030             if (!moduleInfo.hasExportStarsToExportValues) {
78031                 return;
78032             }
78033             if (!moduleInfo.exportedNames && moduleInfo.exportSpecifiers.size === 0) {
78034                 var hasExportDeclarationWithExportClause = false;
78035                 for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) {
78036                     var externalImport = _a[_i];
78037                     if (externalImport.kind === 267 && externalImport.exportClause) {
78038                         hasExportDeclarationWithExportClause = true;
78039                         break;
78040                     }
78041                 }
78042                 if (!hasExportDeclarationWithExportClause) {
78043                     var exportStarFunction_1 = createExportStarFunction(undefined);
78044                     statements.push(exportStarFunction_1);
78045                     return exportStarFunction_1.name;
78046                 }
78047             }
78048             var exportedNames = [];
78049             if (moduleInfo.exportedNames) {
78050                 for (var _b = 0, _c = moduleInfo.exportedNames; _b < _c.length; _b++) {
78051                     var exportedLocalName = _c[_b];
78052                     if (exportedLocalName.escapedText === "default") {
78053                         continue;
78054                     }
78055                     exportedNames.push(factory.createPropertyAssignment(factory.createStringLiteralFromNode(exportedLocalName), factory.createTrue()));
78056                 }
78057             }
78058             var exportedNamesStorageRef = factory.createUniqueName("exportedNames");
78059             statements.push(factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
78060                 factory.createVariableDeclaration(exportedNamesStorageRef, undefined, undefined, factory.createObjectLiteralExpression(exportedNames, true))
78061             ])));
78062             var exportStarFunction = createExportStarFunction(exportedNamesStorageRef);
78063             statements.push(exportStarFunction);
78064             return exportStarFunction.name;
78065         }
78066         function createExportStarFunction(localNames) {
78067             var exportStarFunction = factory.createUniqueName("exportStar");
78068             var m = factory.createIdentifier("m");
78069             var n = factory.createIdentifier("n");
78070             var exports = factory.createIdentifier("exports");
78071             var condition = factory.createStrictInequality(n, factory.createStringLiteral("default"));
78072             if (localNames) {
78073                 condition = factory.createLogicalAnd(condition, factory.createLogicalNot(factory.createCallExpression(factory.createPropertyAccessExpression(localNames, "hasOwnProperty"), undefined, [n])));
78074             }
78075             return factory.createFunctionDeclaration(undefined, undefined, undefined, exportStarFunction, undefined, [factory.createParameterDeclaration(undefined, undefined, undefined, m)], undefined, factory.createBlock([
78076                 factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
78077                     factory.createVariableDeclaration(exports, undefined, undefined, factory.createObjectLiteralExpression([]))
78078                 ])),
78079                 factory.createForInStatement(factory.createVariableDeclarationList([
78080                     factory.createVariableDeclaration(n)
78081                 ]), m, factory.createBlock([
78082                     ts.setEmitFlags(factory.createIfStatement(condition, factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(exports, n), factory.createElementAccessExpression(m, n)))), 1)
78083                 ])),
78084                 factory.createExpressionStatement(factory.createCallExpression(exportFunction, undefined, [exports]))
78085             ], true));
78086         }
78087         function createSettersArray(exportStarFunction, dependencyGroups) {
78088             var setters = [];
78089             for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) {
78090                 var group_2 = dependencyGroups_1[_i];
78091                 var localName = ts.forEach(group_2.externalImports, function (i) { return ts.getLocalNameForExternalImport(factory, i, currentSourceFile); });
78092                 var parameterName = localName ? factory.getGeneratedNameForNode(localName) : factory.createUniqueName("");
78093                 var statements = [];
78094                 for (var _a = 0, _b = group_2.externalImports; _a < _b.length; _a++) {
78095                     var entry = _b[_a];
78096                     var importVariableName = ts.getLocalNameForExternalImport(factory, entry, currentSourceFile);
78097                     switch (entry.kind) {
78098                         case 261:
78099                             if (!entry.importClause) {
78100                                 break;
78101                             }
78102                         case 260:
78103                             ts.Debug.assert(importVariableName !== undefined);
78104                             statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName)));
78105                             break;
78106                         case 267:
78107                             ts.Debug.assert(importVariableName !== undefined);
78108                             if (entry.exportClause) {
78109                                 if (ts.isNamedExports(entry.exportClause)) {
78110                                     var properties = [];
78111                                     for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) {
78112                                         var e = _d[_c];
78113                                         properties.push(factory.createPropertyAssignment(factory.createStringLiteral(ts.idText(e.name)), factory.createElementAccessExpression(parameterName, factory.createStringLiteral(ts.idText(e.propertyName || e.name)))));
78114                                     }
78115                                     statements.push(factory.createExpressionStatement(factory.createCallExpression(exportFunction, undefined, [factory.createObjectLiteralExpression(properties, true)])));
78116                                 }
78117                                 else {
78118                                     statements.push(factory.createExpressionStatement(factory.createCallExpression(exportFunction, undefined, [
78119                                         factory.createStringLiteral(ts.idText(entry.exportClause.name)),
78120                                         parameterName
78121                                     ])));
78122                                 }
78123                             }
78124                             else {
78125                                 statements.push(factory.createExpressionStatement(factory.createCallExpression(exportStarFunction, undefined, [parameterName])));
78126                             }
78127                             break;
78128                     }
78129                 }
78130                 setters.push(factory.createFunctionExpression(undefined, undefined, undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, undefined, parameterName)], undefined, factory.createBlock(statements, true)));
78131             }
78132             return factory.createArrayLiteralExpression(setters, true);
78133         }
78134         function sourceElementVisitor(node) {
78135             switch (node.kind) {
78136                 case 261:
78137                     return visitImportDeclaration(node);
78138                 case 260:
78139                     return visitImportEqualsDeclaration(node);
78140                 case 267:
78141                     return visitExportDeclaration(node);
78142                 case 266:
78143                     return visitExportAssignment(node);
78144                 default:
78145                     return nestedElementVisitor(node);
78146             }
78147         }
78148         function visitImportDeclaration(node) {
78149             var statements;
78150             if (node.importClause) {
78151                 hoistVariableDeclaration(ts.getLocalNameForExternalImport(factory, node, currentSourceFile));
78152             }
78153             if (hasAssociatedEndOfDeclarationMarker(node)) {
78154                 var id = ts.getOriginalNodeId(node);
78155                 deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node);
78156             }
78157             else {
78158                 statements = appendExportsOfImportDeclaration(statements, node);
78159             }
78160             return ts.singleOrMany(statements);
78161         }
78162         function visitExportDeclaration(node) {
78163             ts.Debug.assertIsDefined(node);
78164             return undefined;
78165         }
78166         function visitImportEqualsDeclaration(node) {
78167             ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer.");
78168             var statements;
78169             hoistVariableDeclaration(ts.getLocalNameForExternalImport(factory, node, currentSourceFile));
78170             if (hasAssociatedEndOfDeclarationMarker(node)) {
78171                 var id = ts.getOriginalNodeId(node);
78172                 deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node);
78173             }
78174             else {
78175                 statements = appendExportsOfImportEqualsDeclaration(statements, node);
78176             }
78177             return ts.singleOrMany(statements);
78178         }
78179         function visitExportAssignment(node) {
78180             if (node.isExportEquals) {
78181                 return undefined;
78182             }
78183             var expression = ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression);
78184             var original = node.original;
78185             if (original && hasAssociatedEndOfDeclarationMarker(original)) {
78186                 var id = ts.getOriginalNodeId(node);
78187                 deferredExports[id] = appendExportStatement(deferredExports[id], factory.createIdentifier("default"), expression, true);
78188             }
78189             else {
78190                 return createExportStatement(factory.createIdentifier("default"), expression, true);
78191             }
78192         }
78193         function visitFunctionDeclaration(node) {
78194             if (ts.hasSyntacticModifier(node, 1)) {
78195                 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)));
78196             }
78197             else {
78198                 hoistedStatements = ts.append(hoistedStatements, ts.visitEachChild(node, destructuringAndImportCallVisitor, context));
78199             }
78200             if (hasAssociatedEndOfDeclarationMarker(node)) {
78201                 var id = ts.getOriginalNodeId(node);
78202                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
78203             }
78204             else {
78205                 hoistedStatements = appendExportsOfHoistedDeclaration(hoistedStatements, node);
78206             }
78207             return undefined;
78208         }
78209         function visitClassDeclaration(node) {
78210             var statements;
78211             var name = factory.getLocalName(node);
78212             hoistVariableDeclaration(name);
78213             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));
78214             if (hasAssociatedEndOfDeclarationMarker(node)) {
78215                 var id = ts.getOriginalNodeId(node);
78216                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
78217             }
78218             else {
78219                 statements = appendExportsOfHoistedDeclaration(statements, node);
78220             }
78221             return ts.singleOrMany(statements);
78222         }
78223         function visitVariableStatement(node) {
78224             if (!shouldHoistVariableDeclarationList(node.declarationList)) {
78225                 return ts.visitNode(node, destructuringAndImportCallVisitor, ts.isStatement);
78226             }
78227             var expressions;
78228             var isExportedDeclaration = ts.hasSyntacticModifier(node, 1);
78229             var isMarkedDeclaration = hasAssociatedEndOfDeclarationMarker(node);
78230             for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
78231                 var variable = _a[_i];
78232                 if (variable.initializer) {
78233                     expressions = ts.append(expressions, transformInitializedVariable(variable, isExportedDeclaration && !isMarkedDeclaration));
78234                 }
78235                 else {
78236                     hoistBindingElement(variable);
78237                 }
78238             }
78239             var statements;
78240             if (expressions) {
78241                 statements = ts.append(statements, ts.setTextRange(factory.createExpressionStatement(factory.inlineExpressions(expressions)), node));
78242             }
78243             if (isMarkedDeclaration) {
78244                 var id = ts.getOriginalNodeId(node);
78245                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node, isExportedDeclaration);
78246             }
78247             else {
78248                 statements = appendExportsOfVariableStatement(statements, node, false);
78249             }
78250             return ts.singleOrMany(statements);
78251         }
78252         function hoistBindingElement(node) {
78253             if (ts.isBindingPattern(node.name)) {
78254                 for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) {
78255                     var element = _a[_i];
78256                     if (!ts.isOmittedExpression(element)) {
78257                         hoistBindingElement(element);
78258                     }
78259                 }
78260             }
78261             else {
78262                 hoistVariableDeclaration(factory.cloneNode(node.name));
78263             }
78264         }
78265         function shouldHoistVariableDeclarationList(node) {
78266             return (ts.getEmitFlags(node) & 2097152) === 0
78267                 && (enclosingBlockScopedContainer.kind === 297
78268                     || (ts.getOriginalNode(node).flags & 3) === 0);
78269         }
78270         function transformInitializedVariable(node, isExportedDeclaration) {
78271             var createAssignment = isExportedDeclaration ? createExportedVariableAssignment : createNonExportedVariableAssignment;
78272             return ts.isBindingPattern(node.name)
78273                 ? ts.flattenDestructuringAssignment(node, destructuringAndImportCallVisitor, context, 0, false, createAssignment)
78274                 : node.initializer ? createAssignment(node.name, ts.visitNode(node.initializer, destructuringAndImportCallVisitor, ts.isExpression)) : node.name;
78275         }
78276         function createExportedVariableAssignment(name, value, location) {
78277             return createVariableAssignment(name, value, location, true);
78278         }
78279         function createNonExportedVariableAssignment(name, value, location) {
78280             return createVariableAssignment(name, value, location, false);
78281         }
78282         function createVariableAssignment(name, value, location, isExportedDeclaration) {
78283             hoistVariableDeclaration(factory.cloneNode(name));
78284             return isExportedDeclaration
78285                 ? createExportExpression(name, preventSubstitution(ts.setTextRange(factory.createAssignment(name, value), location)))
78286                 : preventSubstitution(ts.setTextRange(factory.createAssignment(name, value), location));
78287         }
78288         function visitMergeDeclarationMarker(node) {
78289             if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 232) {
78290                 var id = ts.getOriginalNodeId(node);
78291                 var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1);
78292                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration);
78293             }
78294             return node;
78295         }
78296         function hasAssociatedEndOfDeclarationMarker(node) {
78297             return (ts.getEmitFlags(node) & 4194304) !== 0;
78298         }
78299         function visitEndOfDeclarationMarker(node) {
78300             var id = ts.getOriginalNodeId(node);
78301             var statements = deferredExports[id];
78302             if (statements) {
78303                 delete deferredExports[id];
78304                 return ts.append(statements, node);
78305             }
78306             else {
78307                 var original = ts.getOriginalNode(node);
78308                 if (ts.isModuleOrEnumDeclaration(original)) {
78309                     return ts.append(appendExportsOfDeclaration(statements, original), node);
78310                 }
78311             }
78312             return node;
78313         }
78314         function appendExportsOfImportDeclaration(statements, decl) {
78315             if (moduleInfo.exportEquals) {
78316                 return statements;
78317             }
78318             var importClause = decl.importClause;
78319             if (!importClause) {
78320                 return statements;
78321             }
78322             if (importClause.name) {
78323                 statements = appendExportsOfDeclaration(statements, importClause);
78324             }
78325             var namedBindings = importClause.namedBindings;
78326             if (namedBindings) {
78327                 switch (namedBindings.kind) {
78328                     case 263:
78329                         statements = appendExportsOfDeclaration(statements, namedBindings);
78330                         break;
78331                     case 264:
78332                         for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) {
78333                             var importBinding = _a[_i];
78334                             statements = appendExportsOfDeclaration(statements, importBinding);
78335                         }
78336                         break;
78337                 }
78338             }
78339             return statements;
78340         }
78341         function appendExportsOfImportEqualsDeclaration(statements, decl) {
78342             if (moduleInfo.exportEquals) {
78343                 return statements;
78344             }
78345             return appendExportsOfDeclaration(statements, decl);
78346         }
78347         function appendExportsOfVariableStatement(statements, node, exportSelf) {
78348             if (moduleInfo.exportEquals) {
78349                 return statements;
78350             }
78351             for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
78352                 var decl = _a[_i];
78353                 if (decl.initializer || exportSelf) {
78354                     statements = appendExportsOfBindingElement(statements, decl, exportSelf);
78355                 }
78356             }
78357             return statements;
78358         }
78359         function appendExportsOfBindingElement(statements, decl, exportSelf) {
78360             if (moduleInfo.exportEquals) {
78361                 return statements;
78362             }
78363             if (ts.isBindingPattern(decl.name)) {
78364                 for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) {
78365                     var element = _a[_i];
78366                     if (!ts.isOmittedExpression(element)) {
78367                         statements = appendExportsOfBindingElement(statements, element, exportSelf);
78368                     }
78369                 }
78370             }
78371             else if (!ts.isGeneratedIdentifier(decl.name)) {
78372                 var excludeName = void 0;
78373                 if (exportSelf) {
78374                     statements = appendExportStatement(statements, decl.name, factory.getLocalName(decl));
78375                     excludeName = ts.idText(decl.name);
78376                 }
78377                 statements = appendExportsOfDeclaration(statements, decl, excludeName);
78378             }
78379             return statements;
78380         }
78381         function appendExportsOfHoistedDeclaration(statements, decl) {
78382             if (moduleInfo.exportEquals) {
78383                 return statements;
78384             }
78385             var excludeName;
78386             if (ts.hasSyntacticModifier(decl, 1)) {
78387                 var exportName = ts.hasSyntacticModifier(decl, 512) ? factory.createStringLiteral("default") : decl.name;
78388                 statements = appendExportStatement(statements, exportName, factory.getLocalName(decl));
78389                 excludeName = ts.getTextOfIdentifierOrLiteral(exportName);
78390             }
78391             if (decl.name) {
78392                 statements = appendExportsOfDeclaration(statements, decl, excludeName);
78393             }
78394             return statements;
78395         }
78396         function appendExportsOfDeclaration(statements, decl, excludeName) {
78397             if (moduleInfo.exportEquals) {
78398                 return statements;
78399             }
78400             var name = factory.getDeclarationName(decl);
78401             var exportSpecifiers = moduleInfo.exportSpecifiers.get(ts.idText(name));
78402             if (exportSpecifiers) {
78403                 for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) {
78404                     var exportSpecifier = exportSpecifiers_2[_i];
78405                     if (exportSpecifier.name.escapedText !== excludeName) {
78406                         statements = appendExportStatement(statements, exportSpecifier.name, name);
78407                     }
78408                 }
78409             }
78410             return statements;
78411         }
78412         function appendExportStatement(statements, exportName, expression, allowComments) {
78413             statements = ts.append(statements, createExportStatement(exportName, expression, allowComments));
78414             return statements;
78415         }
78416         function createExportStatement(name, value, allowComments) {
78417             var statement = factory.createExpressionStatement(createExportExpression(name, value));
78418             ts.startOnNewLine(statement);
78419             if (!allowComments) {
78420                 ts.setEmitFlags(statement, 1536);
78421             }
78422             return statement;
78423         }
78424         function createExportExpression(name, value) {
78425             var exportName = ts.isIdentifier(name) ? factory.createStringLiteralFromNode(name) : name;
78426             ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536);
78427             return ts.setCommentRange(factory.createCallExpression(exportFunction, undefined, [exportName, value]), value);
78428         }
78429         function nestedElementVisitor(node) {
78430             switch (node.kind) {
78431                 case 232:
78432                     return visitVariableStatement(node);
78433                 case 251:
78434                     return visitFunctionDeclaration(node);
78435                 case 252:
78436                     return visitClassDeclaration(node);
78437                 case 237:
78438                     return visitForStatement(node);
78439                 case 238:
78440                     return visitForInStatement(node);
78441                 case 239:
78442                     return visitForOfStatement(node);
78443                 case 235:
78444                     return visitDoStatement(node);
78445                 case 236:
78446                     return visitWhileStatement(node);
78447                 case 245:
78448                     return visitLabeledStatement(node);
78449                 case 243:
78450                     return visitWithStatement(node);
78451                 case 244:
78452                     return visitSwitchStatement(node);
78453                 case 258:
78454                     return visitCaseBlock(node);
78455                 case 284:
78456                     return visitCaseClause(node);
78457                 case 285:
78458                     return visitDefaultClause(node);
78459                 case 247:
78460                     return visitTryStatement(node);
78461                 case 287:
78462                     return visitCatchClause(node);
78463                 case 230:
78464                     return visitBlock(node);
78465                 case 338:
78466                     return visitMergeDeclarationMarker(node);
78467                 case 339:
78468                     return visitEndOfDeclarationMarker(node);
78469                 default:
78470                     return destructuringAndImportCallVisitor(node);
78471             }
78472         }
78473         function visitForStatement(node) {
78474             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
78475             enclosingBlockScopedContainer = node;
78476             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));
78477             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
78478             return node;
78479         }
78480         function visitForInStatement(node) {
78481             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
78482             enclosingBlockScopedContainer = node;
78483             node = factory.updateForInStatement(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock));
78484             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
78485             return node;
78486         }
78487         function visitForOfStatement(node) {
78488             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
78489             enclosingBlockScopedContainer = node;
78490             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));
78491             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
78492             return node;
78493         }
78494         function shouldHoistForInitializer(node) {
78495             return ts.isVariableDeclarationList(node)
78496                 && shouldHoistVariableDeclarationList(node);
78497         }
78498         function visitForInitializer(node) {
78499             if (shouldHoistForInitializer(node)) {
78500                 var expressions = void 0;
78501                 for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) {
78502                     var variable = _a[_i];
78503                     expressions = ts.append(expressions, transformInitializedVariable(variable, false));
78504                     if (!variable.initializer) {
78505                         hoistBindingElement(variable);
78506                     }
78507                 }
78508                 return expressions ? factory.inlineExpressions(expressions) : factory.createOmittedExpression();
78509             }
78510             else {
78511                 return ts.visitEachChild(node, nestedElementVisitor, context);
78512             }
78513         }
78514         function visitDoStatement(node) {
78515             return factory.updateDoStatement(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression));
78516         }
78517         function visitWhileStatement(node) {
78518             return factory.updateWhileStatement(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock));
78519         }
78520         function visitLabeledStatement(node) {
78521             return factory.updateLabeledStatement(node, node.label, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock));
78522         }
78523         function visitWithStatement(node) {
78524             return factory.updateWithStatement(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock));
78525         }
78526         function visitSwitchStatement(node) {
78527             return factory.updateSwitchStatement(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.caseBlock, nestedElementVisitor, ts.isCaseBlock));
78528         }
78529         function visitCaseBlock(node) {
78530             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
78531             enclosingBlockScopedContainer = node;
78532             node = factory.updateCaseBlock(node, ts.visitNodes(node.clauses, nestedElementVisitor, ts.isCaseOrDefaultClause));
78533             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
78534             return node;
78535         }
78536         function visitCaseClause(node) {
78537             return factory.updateCaseClause(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNodes(node.statements, nestedElementVisitor, ts.isStatement));
78538         }
78539         function visitDefaultClause(node) {
78540             return ts.visitEachChild(node, nestedElementVisitor, context);
78541         }
78542         function visitTryStatement(node) {
78543             return ts.visitEachChild(node, nestedElementVisitor, context);
78544         }
78545         function visitCatchClause(node) {
78546             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
78547             enclosingBlockScopedContainer = node;
78548             node = factory.updateCatchClause(node, node.variableDeclaration, ts.visitNode(node.block, nestedElementVisitor, ts.isBlock));
78549             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
78550             return node;
78551         }
78552         function visitBlock(node) {
78553             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
78554             enclosingBlockScopedContainer = node;
78555             node = ts.visitEachChild(node, nestedElementVisitor, context);
78556             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
78557             return node;
78558         }
78559         function destructuringAndImportCallVisitor(node) {
78560             if (ts.isDestructuringAssignment(node)) {
78561                 return visitDestructuringAssignment(node);
78562             }
78563             else if (ts.isImportCall(node)) {
78564                 return visitImportCallExpression(node);
78565             }
78566             else if ((node.transformFlags & 1024) || (node.transformFlags & 2097152)) {
78567                 return ts.visitEachChild(node, destructuringAndImportCallVisitor, context);
78568             }
78569             else {
78570                 return node;
78571             }
78572         }
78573         function visitImportCallExpression(node) {
78574             return factory.createCallExpression(factory.createPropertyAccessExpression(contextObject, factory.createIdentifier("import")), undefined, ts.some(node.arguments) ? [ts.visitNode(node.arguments[0], destructuringAndImportCallVisitor)] : []);
78575         }
78576         function visitDestructuringAssignment(node) {
78577             if (hasExportedReferenceInDestructuringTarget(node.left)) {
78578                 return ts.flattenDestructuringAssignment(node, destructuringAndImportCallVisitor, context, 0, true);
78579             }
78580             return ts.visitEachChild(node, destructuringAndImportCallVisitor, context);
78581         }
78582         function hasExportedReferenceInDestructuringTarget(node) {
78583             if (ts.isAssignmentExpression(node, true)) {
78584                 return hasExportedReferenceInDestructuringTarget(node.left);
78585             }
78586             else if (ts.isSpreadElement(node)) {
78587                 return hasExportedReferenceInDestructuringTarget(node.expression);
78588             }
78589             else if (ts.isObjectLiteralExpression(node)) {
78590                 return ts.some(node.properties, hasExportedReferenceInDestructuringTarget);
78591             }
78592             else if (ts.isArrayLiteralExpression(node)) {
78593                 return ts.some(node.elements, hasExportedReferenceInDestructuringTarget);
78594             }
78595             else if (ts.isShorthandPropertyAssignment(node)) {
78596                 return hasExportedReferenceInDestructuringTarget(node.name);
78597             }
78598             else if (ts.isPropertyAssignment(node)) {
78599                 return hasExportedReferenceInDestructuringTarget(node.initializer);
78600             }
78601             else if (ts.isIdentifier(node)) {
78602                 var container = resolver.getReferencedExportContainer(node);
78603                 return container !== undefined && container.kind === 297;
78604             }
78605             else {
78606                 return false;
78607             }
78608         }
78609         function modifierVisitor(node) {
78610             switch (node.kind) {
78611                 case 92:
78612                 case 87:
78613                     return undefined;
78614             }
78615             return node;
78616         }
78617         function onEmitNode(hint, node, emitCallback) {
78618             if (node.kind === 297) {
78619                 var id = ts.getOriginalNodeId(node);
78620                 currentSourceFile = node;
78621                 moduleInfo = moduleInfoMap[id];
78622                 exportFunction = exportFunctionsMap[id];
78623                 noSubstitution = noSubstitutionMap[id];
78624                 contextObject = contextObjectMap[id];
78625                 if (noSubstitution) {
78626                     delete noSubstitutionMap[id];
78627                 }
78628                 previousOnEmitNode(hint, node, emitCallback);
78629                 currentSourceFile = undefined;
78630                 moduleInfo = undefined;
78631                 exportFunction = undefined;
78632                 contextObject = undefined;
78633                 noSubstitution = undefined;
78634             }
78635             else {
78636                 previousOnEmitNode(hint, node, emitCallback);
78637             }
78638         }
78639         function onSubstituteNode(hint, node) {
78640             node = previousOnSubstituteNode(hint, node);
78641             if (isSubstitutionPrevented(node)) {
78642                 return node;
78643             }
78644             if (hint === 1) {
78645                 return substituteExpression(node);
78646             }
78647             else if (hint === 4) {
78648                 return substituteUnspecified(node);
78649             }
78650             return node;
78651         }
78652         function substituteUnspecified(node) {
78653             switch (node.kind) {
78654                 case 289:
78655                     return substituteShorthandPropertyAssignment(node);
78656             }
78657             return node;
78658         }
78659         function substituteShorthandPropertyAssignment(node) {
78660             var name = node.name;
78661             if (!ts.isGeneratedIdentifier(name) && !ts.isLocalName(name)) {
78662                 var importDeclaration = resolver.getReferencedImportDeclaration(name);
78663                 if (importDeclaration) {
78664                     if (ts.isImportClause(importDeclaration)) {
78665                         return ts.setTextRange(factory.createPropertyAssignment(factory.cloneNode(name), factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(importDeclaration.parent), factory.createIdentifier("default"))), node);
78666                     }
78667                     else if (ts.isImportSpecifier(importDeclaration)) {
78668                         return ts.setTextRange(factory.createPropertyAssignment(factory.cloneNode(name), factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(importDeclaration.parent.parent.parent), factory.cloneNode(importDeclaration.propertyName || importDeclaration.name))), node);
78669                     }
78670                 }
78671             }
78672             return node;
78673         }
78674         function substituteExpression(node) {
78675             switch (node.kind) {
78676                 case 78:
78677                     return substituteExpressionIdentifier(node);
78678                 case 216:
78679                     return substituteBinaryExpression(node);
78680                 case 214:
78681                 case 215:
78682                     return substituteUnaryExpression(node);
78683                 case 226:
78684                     return substituteMetaProperty(node);
78685             }
78686             return node;
78687         }
78688         function substituteExpressionIdentifier(node) {
78689             if (ts.getEmitFlags(node) & 4096) {
78690                 var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile);
78691                 if (externalHelpersModuleName) {
78692                     return factory.createPropertyAccessExpression(externalHelpersModuleName, node);
78693                 }
78694                 return node;
78695             }
78696             if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) {
78697                 var importDeclaration = resolver.getReferencedImportDeclaration(node);
78698                 if (importDeclaration) {
78699                     if (ts.isImportClause(importDeclaration)) {
78700                         return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(importDeclaration.parent), factory.createIdentifier("default")), node);
78701                     }
78702                     else if (ts.isImportSpecifier(importDeclaration)) {
78703                         return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(importDeclaration.parent.parent.parent), factory.cloneNode(importDeclaration.propertyName || importDeclaration.name)), node);
78704                     }
78705                 }
78706             }
78707             return node;
78708         }
78709         function substituteBinaryExpression(node) {
78710             if (ts.isAssignmentOperator(node.operatorToken.kind)
78711                 && ts.isIdentifier(node.left)
78712                 && !ts.isGeneratedIdentifier(node.left)
78713                 && !ts.isLocalName(node.left)
78714                 && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) {
78715                 var exportedNames = getExports(node.left);
78716                 if (exportedNames) {
78717                     var expression = node;
78718                     for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) {
78719                         var exportName = exportedNames_4[_i];
78720                         expression = createExportExpression(exportName, preventSubstitution(expression));
78721                     }
78722                     return expression;
78723                 }
78724             }
78725             return node;
78726         }
78727         function substituteUnaryExpression(node) {
78728             if ((node.operator === 45 || node.operator === 46)
78729                 && ts.isIdentifier(node.operand)
78730                 && !ts.isGeneratedIdentifier(node.operand)
78731                 && !ts.isLocalName(node.operand)
78732                 && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) {
78733                 var exportedNames = getExports(node.operand);
78734                 if (exportedNames) {
78735                     var expression = node.kind === 215
78736                         ? ts.setTextRange(factory.createPrefixUnaryExpression(node.operator, node.operand), node)
78737                         : node;
78738                     for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) {
78739                         var exportName = exportedNames_5[_i];
78740                         expression = createExportExpression(exportName, preventSubstitution(expression));
78741                     }
78742                     if (node.kind === 215) {
78743                         expression = node.operator === 45
78744                             ? factory.createSubtract(preventSubstitution(expression), factory.createNumericLiteral(1))
78745                             : factory.createAdd(preventSubstitution(expression), factory.createNumericLiteral(1));
78746                     }
78747                     return expression;
78748                 }
78749             }
78750             return node;
78751         }
78752         function substituteMetaProperty(node) {
78753             if (ts.isImportMeta(node)) {
78754                 return factory.createPropertyAccessExpression(contextObject, factory.createIdentifier("meta"));
78755             }
78756             return node;
78757         }
78758         function getExports(name) {
78759             var exportedNames;
78760             if (!ts.isGeneratedIdentifier(name)) {
78761                 var valueDeclaration = resolver.getReferencedImportDeclaration(name)
78762                     || resolver.getReferencedValueDeclaration(name);
78763                 if (valueDeclaration) {
78764                     var exportContainer = resolver.getReferencedExportContainer(name, false);
78765                     if (exportContainer && exportContainer.kind === 297) {
78766                         exportedNames = ts.append(exportedNames, factory.getDeclarationName(valueDeclaration));
78767                     }
78768                     exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]);
78769                 }
78770             }
78771             return exportedNames;
78772         }
78773         function preventSubstitution(node) {
78774             if (noSubstitution === undefined)
78775                 noSubstitution = [];
78776             noSubstitution[ts.getNodeId(node)] = true;
78777             return node;
78778         }
78779         function isSubstitutionPrevented(node) {
78780             return noSubstitution && node.id && noSubstitution[node.id];
78781         }
78782     }
78783     ts.transformSystemModule = transformSystemModule;
78784 })(ts || (ts = {}));
78785 var ts;
78786 (function (ts) {
78787     function transformECMAScriptModule(context) {
78788         var factory = context.factory, emitHelpers = context.getEmitHelperFactory;
78789         var compilerOptions = context.getCompilerOptions();
78790         var previousOnEmitNode = context.onEmitNode;
78791         var previousOnSubstituteNode = context.onSubstituteNode;
78792         context.onEmitNode = onEmitNode;
78793         context.onSubstituteNode = onSubstituteNode;
78794         context.enableEmitNotification(297);
78795         context.enableSubstitution(78);
78796         var helperNameSubstitutions;
78797         return ts.chainBundle(context, transformSourceFile);
78798         function transformSourceFile(node) {
78799             if (node.isDeclarationFile) {
78800                 return node;
78801             }
78802             if (ts.isExternalModule(node) || compilerOptions.isolatedModules) {
78803                 var result = updateExternalModule(node);
78804                 if (!ts.isExternalModule(node) || ts.some(result.statements, ts.isExternalModuleIndicator)) {
78805                     return result;
78806                 }
78807                 return factory.updateSourceFile(result, ts.setTextRange(factory.createNodeArray(__spreadArrays(result.statements, [ts.createEmptyExports(factory)])), result.statements));
78808             }
78809             return node;
78810         }
78811         function updateExternalModule(node) {
78812             var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(factory, emitHelpers(), node, compilerOptions);
78813             if (externalHelpersImportDeclaration) {
78814                 var statements = [];
78815                 var statementOffset = factory.copyPrologue(node.statements, statements);
78816                 ts.append(statements, externalHelpersImportDeclaration);
78817                 ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset));
78818                 return factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray(statements), node.statements));
78819             }
78820             else {
78821                 return ts.visitEachChild(node, visitor, context);
78822             }
78823         }
78824         function visitor(node) {
78825             switch (node.kind) {
78826                 case 260:
78827                     return undefined;
78828                 case 266:
78829                     return visitExportAssignment(node);
78830                 case 267:
78831                     var exportDecl = node;
78832                     return visitExportDeclaration(exportDecl);
78833             }
78834             return node;
78835         }
78836         function visitExportAssignment(node) {
78837             return node.isExportEquals ? undefined : node;
78838         }
78839         function visitExportDeclaration(node) {
78840             if (compilerOptions.module !== undefined && compilerOptions.module > ts.ModuleKind.ES2015) {
78841                 return node;
78842             }
78843             if (!node.exportClause || !ts.isNamespaceExport(node.exportClause) || !node.moduleSpecifier) {
78844                 return node;
78845             }
78846             var oldIdentifier = node.exportClause.name;
78847             var synthName = factory.getGeneratedNameForNode(oldIdentifier);
78848             var importDecl = factory.createImportDeclaration(undefined, undefined, factory.createImportClause(false, undefined, factory.createNamespaceImport(synthName)), node.moduleSpecifier);
78849             ts.setOriginalNode(importDecl, node.exportClause);
78850             var exportDecl = ts.isExportNamespaceAsDefaultDeclaration(node) ? factory.createExportDefault(synthName) : factory.createExportDeclaration(undefined, undefined, false, factory.createNamedExports([factory.createExportSpecifier(synthName, oldIdentifier)]));
78851             ts.setOriginalNode(exportDecl, node);
78852             return [importDecl, exportDecl];
78853         }
78854         function onEmitNode(hint, node, emitCallback) {
78855             if (ts.isSourceFile(node)) {
78856                 if ((ts.isExternalModule(node) || compilerOptions.isolatedModules) && compilerOptions.importHelpers) {
78857                     helperNameSubstitutions = new ts.Map();
78858                 }
78859                 previousOnEmitNode(hint, node, emitCallback);
78860                 helperNameSubstitutions = undefined;
78861             }
78862             else {
78863                 previousOnEmitNode(hint, node, emitCallback);
78864             }
78865         }
78866         function onSubstituteNode(hint, node) {
78867             node = previousOnSubstituteNode(hint, node);
78868             if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096) {
78869                 return substituteHelperName(node);
78870             }
78871             return node;
78872         }
78873         function substituteHelperName(node) {
78874             var name = ts.idText(node);
78875             var substitution = helperNameSubstitutions.get(name);
78876             if (!substitution) {
78877                 helperNameSubstitutions.set(name, substitution = factory.createUniqueName(name, 16 | 32));
78878             }
78879             return substitution;
78880         }
78881     }
78882     ts.transformECMAScriptModule = transformECMAScriptModule;
78883 })(ts || (ts = {}));
78884 var ts;
78885 (function (ts) {
78886     function canProduceDiagnostics(node) {
78887         return ts.isVariableDeclaration(node) ||
78888             ts.isPropertyDeclaration(node) ||
78889             ts.isPropertySignature(node) ||
78890             ts.isBindingElement(node) ||
78891             ts.isSetAccessor(node) ||
78892             ts.isGetAccessor(node) ||
78893             ts.isConstructSignatureDeclaration(node) ||
78894             ts.isCallSignatureDeclaration(node) ||
78895             ts.isMethodDeclaration(node) ||
78896             ts.isMethodSignature(node) ||
78897             ts.isFunctionDeclaration(node) ||
78898             ts.isParameter(node) ||
78899             ts.isTypeParameterDeclaration(node) ||
78900             ts.isExpressionWithTypeArguments(node) ||
78901             ts.isImportEqualsDeclaration(node) ||
78902             ts.isTypeAliasDeclaration(node) ||
78903             ts.isConstructorDeclaration(node) ||
78904             ts.isIndexSignatureDeclaration(node) ||
78905             ts.isPropertyAccessExpression(node);
78906     }
78907     ts.canProduceDiagnostics = canProduceDiagnostics;
78908     function createGetSymbolAccessibilityDiagnosticForNodeName(node) {
78909         if (ts.isSetAccessor(node) || ts.isGetAccessor(node)) {
78910             return getAccessorNameVisibilityError;
78911         }
78912         else if (ts.isMethodSignature(node) || ts.isMethodDeclaration(node)) {
78913             return getMethodNameVisibilityError;
78914         }
78915         else {
78916             return createGetSymbolAccessibilityDiagnosticForNode(node);
78917         }
78918         function getAccessorNameVisibilityError(symbolAccessibilityResult) {
78919             var diagnosticMessage = getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult);
78920             return diagnosticMessage !== undefined ? {
78921                 diagnosticMessage: diagnosticMessage,
78922                 errorNode: node,
78923                 typeName: node.name
78924             } : undefined;
78925         }
78926         function getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult) {
78927             if (ts.hasSyntacticModifier(node, 32)) {
78928                 return symbolAccessibilityResult.errorModuleName ?
78929                     symbolAccessibilityResult.accessibility === 2 ?
78930                         ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
78931                         ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
78932                     ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1;
78933             }
78934             else if (node.parent.kind === 252) {
78935                 return symbolAccessibilityResult.errorModuleName ?
78936                     symbolAccessibilityResult.accessibility === 2 ?
78937                         ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
78938                         ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
78939                     ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1;
78940             }
78941             else {
78942                 return symbolAccessibilityResult.errorModuleName ?
78943                     ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 :
78944                     ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1;
78945             }
78946         }
78947         function getMethodNameVisibilityError(symbolAccessibilityResult) {
78948             var diagnosticMessage = getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult);
78949             return diagnosticMessage !== undefined ? {
78950                 diagnosticMessage: diagnosticMessage,
78951                 errorNode: node,
78952                 typeName: node.name
78953             } : undefined;
78954         }
78955         function getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult) {
78956             if (ts.hasSyntacticModifier(node, 32)) {
78957                 return symbolAccessibilityResult.errorModuleName ?
78958                     symbolAccessibilityResult.accessibility === 2 ?
78959                         ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
78960                         ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
78961                     ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1;
78962             }
78963             else if (node.parent.kind === 252) {
78964                 return symbolAccessibilityResult.errorModuleName ?
78965                     symbolAccessibilityResult.accessibility === 2 ?
78966                         ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
78967                         ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
78968                     ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_private_name_1;
78969             }
78970             else {
78971                 return symbolAccessibilityResult.errorModuleName ?
78972                     ts.Diagnostics.Method_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 :
78973                     ts.Diagnostics.Method_0_of_exported_interface_has_or_is_using_private_name_1;
78974             }
78975         }
78976     }
78977     ts.createGetSymbolAccessibilityDiagnosticForNodeName = createGetSymbolAccessibilityDiagnosticForNodeName;
78978     function createGetSymbolAccessibilityDiagnosticForNode(node) {
78979         if (ts.isVariableDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertySignature(node) || ts.isPropertyAccessExpression(node) || ts.isBindingElement(node) || ts.isConstructorDeclaration(node)) {
78980             return getVariableDeclarationTypeVisibilityError;
78981         }
78982         else if (ts.isSetAccessor(node) || ts.isGetAccessor(node)) {
78983             return getAccessorDeclarationTypeVisibilityError;
78984         }
78985         else if (ts.isConstructSignatureDeclaration(node) || ts.isCallSignatureDeclaration(node) || ts.isMethodDeclaration(node) || ts.isMethodSignature(node) || ts.isFunctionDeclaration(node) || ts.isIndexSignatureDeclaration(node)) {
78986             return getReturnTypeVisibilityError;
78987         }
78988         else if (ts.isParameter(node)) {
78989             if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasSyntacticModifier(node.parent, 8)) {
78990                 return getVariableDeclarationTypeVisibilityError;
78991             }
78992             return getParameterDeclarationTypeVisibilityError;
78993         }
78994         else if (ts.isTypeParameterDeclaration(node)) {
78995             return getTypeParameterConstraintVisibilityError;
78996         }
78997         else if (ts.isExpressionWithTypeArguments(node)) {
78998             return getHeritageClauseVisibilityError;
78999         }
79000         else if (ts.isImportEqualsDeclaration(node)) {
79001             return getImportEntityNameVisibilityError;
79002         }
79003         else if (ts.isTypeAliasDeclaration(node)) {
79004             return getTypeAliasDeclarationVisibilityError;
79005         }
79006         else {
79007             return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]);
79008         }
79009         function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) {
79010             if (node.kind === 249 || node.kind === 198) {
79011                 return symbolAccessibilityResult.errorModuleName ?
79012                     symbolAccessibilityResult.accessibility === 2 ?
79013                         ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
79014                         ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 :
79015                     ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1;
79016             }
79017             else if (node.kind === 163 || node.kind === 201 || node.kind === 162 ||
79018                 (node.kind === 160 && ts.hasSyntacticModifier(node.parent, 8))) {
79019                 if (ts.hasSyntacticModifier(node, 32)) {
79020                     return symbolAccessibilityResult.errorModuleName ?
79021                         symbolAccessibilityResult.accessibility === 2 ?
79022                             ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
79023                             ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
79024                         ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1;
79025                 }
79026                 else if (node.parent.kind === 252 || node.kind === 160) {
79027                     return symbolAccessibilityResult.errorModuleName ?
79028                         symbolAccessibilityResult.accessibility === 2 ?
79029                             ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
79030                             ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
79031                         ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1;
79032                 }
79033                 else {
79034                     return symbolAccessibilityResult.errorModuleName ?
79035                         ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 :
79036                         ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1;
79037                 }
79038             }
79039         }
79040         function getVariableDeclarationTypeVisibilityError(symbolAccessibilityResult) {
79041             var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult);
79042             return diagnosticMessage !== undefined ? {
79043                 diagnosticMessage: diagnosticMessage,
79044                 errorNode: node,
79045                 typeName: node.name
79046             } : undefined;
79047         }
79048         function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) {
79049             var diagnosticMessage;
79050             if (node.kind === 168) {
79051                 if (ts.hasSyntacticModifier(node, 32)) {
79052                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79053                         ts.Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
79054                         ts.Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_private_name_1;
79055                 }
79056                 else {
79057                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79058                         ts.Diagnostics.Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
79059                         ts.Diagnostics.Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_private_name_1;
79060                 }
79061             }
79062             else {
79063                 if (ts.hasSyntacticModifier(node, 32)) {
79064                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79065                         symbolAccessibilityResult.accessibility === 2 ?
79066                             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 :
79067                             ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
79068                         ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1;
79069                 }
79070                 else {
79071                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79072                         symbolAccessibilityResult.accessibility === 2 ?
79073                             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 :
79074                             ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
79075                         ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1;
79076                 }
79077             }
79078             return {
79079                 diagnosticMessage: diagnosticMessage,
79080                 errorNode: node.name,
79081                 typeName: node.name
79082             };
79083         }
79084         function getReturnTypeVisibilityError(symbolAccessibilityResult) {
79085             var diagnosticMessage;
79086             switch (node.kind) {
79087                 case 170:
79088                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79089                         ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
79090                         ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0;
79091                     break;
79092                 case 169:
79093                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79094                         ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
79095                         ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0;
79096                     break;
79097                 case 171:
79098                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79099                         ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
79100                         ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0;
79101                     break;
79102                 case 165:
79103                 case 164:
79104                     if (ts.hasSyntacticModifier(node, 32)) {
79105                         diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79106                             symbolAccessibilityResult.accessibility === 2 ?
79107                                 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 :
79108                                 ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
79109                             ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0;
79110                     }
79111                     else if (node.parent.kind === 252) {
79112                         diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79113                             symbolAccessibilityResult.accessibility === 2 ?
79114                                 ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
79115                                 ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
79116                             ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0;
79117                     }
79118                     else {
79119                         diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79120                             ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
79121                             ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0;
79122                     }
79123                     break;
79124                 case 251:
79125                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79126                         symbolAccessibilityResult.accessibility === 2 ?
79127                             ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
79128                             ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 :
79129                         ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0;
79130                     break;
79131                 default:
79132                     return ts.Debug.fail("This is unknown kind for signature: " + node.kind);
79133             }
79134             return {
79135                 diagnosticMessage: diagnosticMessage,
79136                 errorNode: node.name || node
79137             };
79138         }
79139         function getParameterDeclarationTypeVisibilityError(symbolAccessibilityResult) {
79140             var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult);
79141             return diagnosticMessage !== undefined ? {
79142                 diagnosticMessage: diagnosticMessage,
79143                 errorNode: node,
79144                 typeName: node.name
79145             } : undefined;
79146         }
79147         function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) {
79148             switch (node.parent.kind) {
79149                 case 166:
79150                     return symbolAccessibilityResult.errorModuleName ?
79151                         symbolAccessibilityResult.accessibility === 2 ?
79152                             ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
79153                             ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
79154                         ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1;
79155                 case 170:
79156                 case 175:
79157                     return symbolAccessibilityResult.errorModuleName ?
79158                         ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
79159                         ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
79160                 case 169:
79161                     return symbolAccessibilityResult.errorModuleName ?
79162                         ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
79163                         ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
79164                 case 171:
79165                     return symbolAccessibilityResult.errorModuleName ?
79166                         ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
79167                         ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1;
79168                 case 165:
79169                 case 164:
79170                     if (ts.hasSyntacticModifier(node.parent, 32)) {
79171                         return symbolAccessibilityResult.errorModuleName ?
79172                             symbolAccessibilityResult.accessibility === 2 ?
79173                                 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 :
79174                                 ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
79175                             ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
79176                     }
79177                     else if (node.parent.parent.kind === 252) {
79178                         return symbolAccessibilityResult.errorModuleName ?
79179                             symbolAccessibilityResult.accessibility === 2 ?
79180                                 ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
79181                                 ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
79182                             ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
79183                     }
79184                     else {
79185                         return symbolAccessibilityResult.errorModuleName ?
79186                             ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
79187                             ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
79188                     }
79189                 case 251:
79190                 case 174:
79191                     return symbolAccessibilityResult.errorModuleName ?
79192                         symbolAccessibilityResult.accessibility === 2 ?
79193                             ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
79194                             ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 :
79195                         ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1;
79196                 case 168:
79197                 case 167:
79198                     return symbolAccessibilityResult.errorModuleName ?
79199                         symbolAccessibilityResult.accessibility === 2 ?
79200                             ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
79201                             ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 :
79202                         ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1;
79203                 default:
79204                     return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]);
79205             }
79206         }
79207         function getTypeParameterConstraintVisibilityError() {
79208             var diagnosticMessage;
79209             switch (node.parent.kind) {
79210                 case 252:
79211                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1;
79212                     break;
79213                 case 253:
79214                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1;
79215                     break;
79216                 case 190:
79217                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1;
79218                     break;
79219                 case 175:
79220                 case 170:
79221                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
79222                     break;
79223                 case 169:
79224                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
79225                     break;
79226                 case 165:
79227                 case 164:
79228                     if (ts.hasSyntacticModifier(node.parent, 32)) {
79229                         diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
79230                     }
79231                     else if (node.parent.parent.kind === 252) {
79232                         diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
79233                     }
79234                     else {
79235                         diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
79236                     }
79237                     break;
79238                 case 174:
79239                 case 251:
79240                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1;
79241                     break;
79242                 case 254:
79243                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1;
79244                     break;
79245                 default:
79246                     return ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind);
79247             }
79248             return {
79249                 diagnosticMessage: diagnosticMessage,
79250                 errorNode: node,
79251                 typeName: node.name
79252             };
79253         }
79254         function getHeritageClauseVisibilityError() {
79255             var diagnosticMessage;
79256             if (ts.isClassDeclaration(node.parent.parent)) {
79257                 diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 116 ?
79258                     ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 :
79259                     node.parent.parent.name ? ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1 :
79260                         ts.Diagnostics.extends_clause_of_exported_class_has_or_is_using_private_name_0;
79261             }
79262             else {
79263                 diagnosticMessage = ts.Diagnostics.extends_clause_of_exported_interface_0_has_or_is_using_private_name_1;
79264             }
79265             return {
79266                 diagnosticMessage: diagnosticMessage,
79267                 errorNode: node,
79268                 typeName: ts.getNameOfDeclaration(node.parent.parent)
79269             };
79270         }
79271         function getImportEntityNameVisibilityError() {
79272             return {
79273                 diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1,
79274                 errorNode: node,
79275                 typeName: node.name
79276             };
79277         }
79278         function getTypeAliasDeclarationVisibilityError() {
79279             return {
79280                 diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1,
79281                 errorNode: node.type,
79282                 typeName: node.name
79283             };
79284         }
79285     }
79286     ts.createGetSymbolAccessibilityDiagnosticForNode = createGetSymbolAccessibilityDiagnosticForNode;
79287 })(ts || (ts = {}));
79288 var ts;
79289 (function (ts) {
79290     function getDeclarationDiagnostics(host, resolver, file) {
79291         var compilerOptions = host.getCompilerOptions();
79292         var result = ts.transformNodes(resolver, host, ts.factory, compilerOptions, file ? [file] : ts.filter(host.getSourceFiles(), ts.isSourceFileNotJson), [transformDeclarations], false);
79293         return result.diagnostics;
79294     }
79295     ts.getDeclarationDiagnostics = getDeclarationDiagnostics;
79296     function hasInternalAnnotation(range, currentSourceFile) {
79297         var comment = currentSourceFile.text.substring(range.pos, range.end);
79298         return ts.stringContains(comment, "@internal");
79299     }
79300     function isInternalDeclaration(node, currentSourceFile) {
79301         var parseTreeNode = ts.getParseTreeNode(node);
79302         if (parseTreeNode && parseTreeNode.kind === 160) {
79303             var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode);
79304             var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined;
79305             var text = currentSourceFile.text;
79306             var commentRanges = previousSibling
79307                 ? ts.concatenate(ts.getTrailingCommentRanges(text, ts.skipTrivia(text, previousSibling.end + 1, false, true)), ts.getLeadingCommentRanges(text, node.pos))
79308                 : ts.getTrailingCommentRanges(text, ts.skipTrivia(text, node.pos, false, true));
79309             return commentRanges && commentRanges.length && hasInternalAnnotation(ts.last(commentRanges), currentSourceFile);
79310         }
79311         var leadingCommentRanges = parseTreeNode && ts.getLeadingCommentRangesOfNode(parseTreeNode, currentSourceFile);
79312         return !!ts.forEach(leadingCommentRanges, function (range) {
79313             return hasInternalAnnotation(range, currentSourceFile);
79314         });
79315     }
79316     ts.isInternalDeclaration = isInternalDeclaration;
79317     var declarationEmitNodeBuilderFlags = 1024 |
79318         2048 |
79319         4096 |
79320         8 |
79321         524288 |
79322         4 |
79323         1;
79324     function transformDeclarations(context) {
79325         var throwDiagnostic = function () { return ts.Debug.fail("Diagnostic emitted without context"); };
79326         var getSymbolAccessibilityDiagnostic = throwDiagnostic;
79327         var needsDeclare = true;
79328         var isBundledEmit = false;
79329         var resultHasExternalModuleIndicator = false;
79330         var needsScopeFixMarker = false;
79331         var resultHasScopeMarker = false;
79332         var enclosingDeclaration;
79333         var necessaryTypeReferences;
79334         var lateMarkedStatements;
79335         var lateStatementReplacementMap;
79336         var suppressNewDiagnosticContexts;
79337         var exportedModulesFromDeclarationEmit;
79338         var factory = context.factory;
79339         var host = context.getEmitHost();
79340         var symbolTracker = {
79341             trackSymbol: trackSymbol,
79342             reportInaccessibleThisError: reportInaccessibleThisError,
79343             reportInaccessibleUniqueSymbolError: reportInaccessibleUniqueSymbolError,
79344             reportCyclicStructureError: reportCyclicStructureError,
79345             reportPrivateInBaseOfClassExpression: reportPrivateInBaseOfClassExpression,
79346             reportLikelyUnsafeImportRequiredError: reportLikelyUnsafeImportRequiredError,
79347             reportTruncationError: reportTruncationError,
79348             moduleResolverHost: host,
79349             trackReferencedAmbientModule: trackReferencedAmbientModule,
79350             trackExternalModuleSymbolOfImportTypeNode: trackExternalModuleSymbolOfImportTypeNode,
79351             reportNonlocalAugmentation: reportNonlocalAugmentation
79352         };
79353         var errorNameNode;
79354         var currentSourceFile;
79355         var refs;
79356         var libs;
79357         var emittedImports;
79358         var resolver = context.getEmitResolver();
79359         var options = context.getCompilerOptions();
79360         var noResolve = options.noResolve, stripInternal = options.stripInternal;
79361         return transformRoot;
79362         function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives) {
79363             if (!typeReferenceDirectives) {
79364                 return;
79365             }
79366             necessaryTypeReferences = necessaryTypeReferences || new ts.Set();
79367             for (var _i = 0, typeReferenceDirectives_2 = typeReferenceDirectives; _i < typeReferenceDirectives_2.length; _i++) {
79368                 var ref = typeReferenceDirectives_2[_i];
79369                 necessaryTypeReferences.add(ref);
79370             }
79371         }
79372         function trackReferencedAmbientModule(node, symbol) {
79373             var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863);
79374             if (ts.length(directives)) {
79375                 return recordTypeReferenceDirectivesIfNecessary(directives);
79376             }
79377             var container = ts.getSourceFileOfNode(node);
79378             refs.set(ts.getOriginalNodeId(container), container);
79379         }
79380         function handleSymbolAccessibilityError(symbolAccessibilityResult) {
79381             if (symbolAccessibilityResult.accessibility === 0) {
79382                 if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) {
79383                     if (!lateMarkedStatements) {
79384                         lateMarkedStatements = symbolAccessibilityResult.aliasesToMakeVisible;
79385                     }
79386                     else {
79387                         for (var _i = 0, _a = symbolAccessibilityResult.aliasesToMakeVisible; _i < _a.length; _i++) {
79388                             var ref = _a[_i];
79389                             ts.pushIfUnique(lateMarkedStatements, ref);
79390                         }
79391                     }
79392                 }
79393             }
79394             else {
79395                 var errorInfo = getSymbolAccessibilityDiagnostic(symbolAccessibilityResult);
79396                 if (errorInfo) {
79397                     if (errorInfo.typeName) {
79398                         context.addDiagnostic(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, ts.getTextOfNode(errorInfo.typeName), symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName));
79399                     }
79400                     else {
79401                         context.addDiagnostic(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName));
79402                     }
79403                 }
79404             }
79405         }
79406         function trackExternalModuleSymbolOfImportTypeNode(symbol) {
79407             if (!isBundledEmit) {
79408                 (exportedModulesFromDeclarationEmit || (exportedModulesFromDeclarationEmit = [])).push(symbol);
79409             }
79410         }
79411         function trackSymbol(symbol, enclosingDeclaration, meaning) {
79412             if (symbol.flags & 262144)
79413                 return;
79414             handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, true));
79415             recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning));
79416         }
79417         function reportPrivateInBaseOfClassExpression(propertyName) {
79418             if (errorNameNode) {
79419                 context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName));
79420             }
79421         }
79422         function reportInaccessibleUniqueSymbolError() {
79423             if (errorNameNode) {
79424                 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"));
79425             }
79426         }
79427         function reportCyclicStructureError() {
79428             if (errorNameNode) {
79429                 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)));
79430             }
79431         }
79432         function reportInaccessibleThisError() {
79433             if (errorNameNode) {
79434                 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"));
79435             }
79436         }
79437         function reportLikelyUnsafeImportRequiredError(specifier) {
79438             if (errorNameNode) {
79439                 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));
79440             }
79441         }
79442         function reportTruncationError() {
79443             if (errorNameNode) {
79444                 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));
79445             }
79446         }
79447         function reportNonlocalAugmentation(containingFile, parentSymbol, symbol) {
79448             var primaryDeclaration = ts.find(parentSymbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === containingFile; });
79449             var augmentingDeclarations = ts.filter(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== containingFile; });
79450             for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) {
79451                 var augmentations = augmentingDeclarations_1[_i];
79452                 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)));
79453             }
79454         }
79455         function transformDeclarationsForJS(sourceFile, bundled) {
79456             var oldDiag = getSymbolAccessibilityDiagnostic;
79457             getSymbolAccessibilityDiagnostic = function (s) { return ({
79458                 diagnosticMessage: s.errorModuleName
79459                     ? ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit
79460                     : ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit,
79461                 errorNode: s.errorNode || sourceFile
79462             }); };
79463             var result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled);
79464             getSymbolAccessibilityDiagnostic = oldDiag;
79465             return result;
79466         }
79467         function transformRoot(node) {
79468             if (node.kind === 297 && node.isDeclarationFile) {
79469                 return node;
79470             }
79471             if (node.kind === 298) {
79472                 isBundledEmit = true;
79473                 refs = new ts.Map();
79474                 libs = new ts.Map();
79475                 var hasNoDefaultLib_1 = false;
79476                 var bundle = factory.createBundle(ts.map(node.sourceFiles, function (sourceFile) {
79477                     if (sourceFile.isDeclarationFile)
79478                         return undefined;
79479                     hasNoDefaultLib_1 = hasNoDefaultLib_1 || sourceFile.hasNoDefaultLib;
79480                     currentSourceFile = sourceFile;
79481                     enclosingDeclaration = sourceFile;
79482                     lateMarkedStatements = undefined;
79483                     suppressNewDiagnosticContexts = false;
79484                     lateStatementReplacementMap = new ts.Map();
79485                     getSymbolAccessibilityDiagnostic = throwDiagnostic;
79486                     needsScopeFixMarker = false;
79487                     resultHasScopeMarker = false;
79488                     collectReferences(sourceFile, refs);
79489                     collectLibs(sourceFile, libs);
79490                     if (ts.isExternalOrCommonJsModule(sourceFile) || ts.isJsonSourceFile(sourceFile)) {
79491                         resultHasExternalModuleIndicator = false;
79492                         needsDeclare = false;
79493                         var statements = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile, true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements);
79494                         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, []);
79495                         return newFile;
79496                     }
79497                     needsDeclare = true;
79498                     var updated = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements);
79499                     return factory.updateSourceFile(sourceFile, transformAndReplaceLatePaintedStatements(updated), true, [], [], false, []);
79500                 }), ts.mapDefined(node.prepends, function (prepend) {
79501                     if (prepend.kind === 300) {
79502                         var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal);
79503                         hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib;
79504                         collectReferences(sourceFile, refs);
79505                         recordTypeReferenceDirectivesIfNecessary(sourceFile.typeReferenceDirectives);
79506                         collectLibs(sourceFile, libs);
79507                         return sourceFile;
79508                     }
79509                     return prepend;
79510                 }));
79511                 bundle.syntheticFileReferences = [];
79512                 bundle.syntheticTypeReferences = getFileReferencesForUsedTypeReferences();
79513                 bundle.syntheticLibReferences = getLibReferences();
79514                 bundle.hasNoDefaultLib = hasNoDefaultLib_1;
79515                 var outputFilePath_1 = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, true).declarationFilePath));
79516                 var referenceVisitor_1 = mapReferencesIntoArray(bundle.syntheticFileReferences, outputFilePath_1);
79517                 refs.forEach(referenceVisitor_1);
79518                 return bundle;
79519             }
79520             needsDeclare = true;
79521             needsScopeFixMarker = false;
79522             resultHasScopeMarker = false;
79523             enclosingDeclaration = node;
79524             currentSourceFile = node;
79525             getSymbolAccessibilityDiagnostic = throwDiagnostic;
79526             isBundledEmit = false;
79527             resultHasExternalModuleIndicator = false;
79528             suppressNewDiagnosticContexts = false;
79529             lateMarkedStatements = undefined;
79530             lateStatementReplacementMap = new ts.Map();
79531             necessaryTypeReferences = undefined;
79532             refs = collectReferences(currentSourceFile, new ts.Map());
79533             libs = collectLibs(currentSourceFile, new ts.Map());
79534             var references = [];
79535             var outputFilePath = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, true).declarationFilePath));
79536             var referenceVisitor = mapReferencesIntoArray(references, outputFilePath);
79537             var combinedStatements;
79538             if (ts.isSourceFileJS(currentSourceFile)) {
79539                 combinedStatements = factory.createNodeArray(transformDeclarationsForJS(node));
79540                 refs.forEach(referenceVisitor);
79541                 emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax);
79542             }
79543             else {
79544                 var statements = ts.visitNodes(node.statements, visitDeclarationStatements);
79545                 combinedStatements = ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements);
79546                 refs.forEach(referenceVisitor);
79547                 emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax);
79548                 if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) {
79549                     combinedStatements = ts.setTextRange(factory.createNodeArray(__spreadArrays(combinedStatements, [ts.createEmptyExports(factory)])), combinedStatements);
79550                 }
79551             }
79552             var updated = factory.updateSourceFile(node, combinedStatements, true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences());
79553             updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit;
79554             return updated;
79555             function getLibReferences() {
79556                 return ts.map(ts.arrayFrom(libs.keys()), function (lib) { return ({ fileName: lib, pos: -1, end: -1 }); });
79557             }
79558             function getFileReferencesForUsedTypeReferences() {
79559                 return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()), getFileReferenceForTypeName) : [];
79560             }
79561             function getFileReferenceForTypeName(typeName) {
79562                 if (emittedImports) {
79563                     for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
79564                         var importStatement = emittedImports_1[_i];
79565                         if (ts.isImportEqualsDeclaration(importStatement) && ts.isExternalModuleReference(importStatement.moduleReference)) {
79566                             var expr = importStatement.moduleReference.expression;
79567                             if (ts.isStringLiteralLike(expr) && expr.text === typeName) {
79568                                 return undefined;
79569                             }
79570                         }
79571                         else if (ts.isImportDeclaration(importStatement) && ts.isStringLiteral(importStatement.moduleSpecifier) && importStatement.moduleSpecifier.text === typeName) {
79572                             return undefined;
79573                         }
79574                     }
79575                 }
79576                 return { fileName: typeName, pos: -1, end: -1 };
79577             }
79578             function mapReferencesIntoArray(references, outputFilePath) {
79579                 return function (file) {
79580                     var declFileName;
79581                     if (file.isDeclarationFile) {
79582                         declFileName = file.fileName;
79583                     }
79584                     else {
79585                         if (isBundledEmit && ts.contains(node.sourceFiles, file))
79586                             return;
79587                         var paths = ts.getOutputPathsFor(file, host, true);
79588                         declFileName = paths.declarationFilePath || paths.jsFilePath || file.fileName;
79589                     }
79590                     if (declFileName) {
79591                         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);
79592                         if (!ts.pathIsRelative(specifier)) {
79593                             recordTypeReferenceDirectivesIfNecessary([specifier]);
79594                             return;
79595                         }
79596                         var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false);
79597                         if (ts.startsWith(fileName, "./") && ts.hasExtension(fileName)) {
79598                             fileName = fileName.substring(2);
79599                         }
79600                         if (ts.startsWith(fileName, "node_modules/") || ts.pathContainsNodeModules(fileName)) {
79601                             return;
79602                         }
79603                         references.push({ pos: -1, end: -1, fileName: fileName });
79604                     }
79605                 };
79606             }
79607         }
79608         function collectReferences(sourceFile, ret) {
79609             if (noResolve || (!ts.isUnparsedSource(sourceFile) && ts.isSourceFileJS(sourceFile)))
79610                 return ret;
79611             ts.forEach(sourceFile.referencedFiles, function (f) {
79612                 var elem = host.getSourceFileFromReference(sourceFile, f);
79613                 if (elem) {
79614                     ret.set(ts.getOriginalNodeId(elem), elem);
79615                 }
79616             });
79617             return ret;
79618         }
79619         function collectLibs(sourceFile, ret) {
79620             ts.forEach(sourceFile.libReferenceDirectives, function (ref) {
79621                 var lib = host.getLibFileFromReference(ref);
79622                 if (lib) {
79623                     ret.set(ts.toFileNameLowerCase(ref.fileName), true);
79624                 }
79625             });
79626             return ret;
79627         }
79628         function filterBindingPatternInitializers(name) {
79629             if (name.kind === 78) {
79630                 return name;
79631             }
79632             else {
79633                 if (name.kind === 197) {
79634                     return factory.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement));
79635                 }
79636                 else {
79637                     return factory.updateObjectBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement));
79638                 }
79639             }
79640             function visitBindingElement(elem) {
79641                 if (elem.kind === 222) {
79642                     return elem;
79643                 }
79644                 return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
79645             }
79646         }
79647         function ensureParameter(p, modifierMask, type) {
79648             var oldDiag;
79649             if (!suppressNewDiagnosticContexts) {
79650                 oldDiag = getSymbolAccessibilityDiagnostic;
79651                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p);
79652             }
79653             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));
79654             if (!suppressNewDiagnosticContexts) {
79655                 getSymbolAccessibilityDiagnostic = oldDiag;
79656             }
79657             return newParam;
79658         }
79659         function shouldPrintWithInitializer(node) {
79660             return canHaveLiteralInitializer(node) && resolver.isLiteralConstDeclaration(ts.getParseTreeNode(node));
79661         }
79662         function ensureNoInitializer(node) {
79663             if (shouldPrintWithInitializer(node)) {
79664                 return resolver.createLiteralConstValue(ts.getParseTreeNode(node), symbolTracker);
79665             }
79666             return undefined;
79667         }
79668         function ensureType(node, type, ignorePrivate) {
79669             if (!ignorePrivate && ts.hasEffectiveModifier(node, 8)) {
79670                 return;
79671             }
79672             if (shouldPrintWithInitializer(node)) {
79673                 return;
79674             }
79675             var shouldUseResolverType = node.kind === 160 &&
79676                 (resolver.isRequiredInitializedParameter(node) ||
79677                     resolver.isOptionalUninitializedParameterProperty(node));
79678             if (type && !shouldUseResolverType) {
79679                 return ts.visitNode(type, visitDeclarationSubtree);
79680             }
79681             if (!ts.getParseTreeNode(node)) {
79682                 return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(128);
79683             }
79684             if (node.kind === 168) {
79685                 return factory.createKeywordTypeNode(128);
79686             }
79687             errorNameNode = node.name;
79688             var oldDiag;
79689             if (!suppressNewDiagnosticContexts) {
79690                 oldDiag = getSymbolAccessibilityDiagnostic;
79691                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node);
79692             }
79693             if (node.kind === 249 || node.kind === 198) {
79694                 return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker));
79695             }
79696             if (node.kind === 160
79697                 || node.kind === 163
79698                 || node.kind === 162) {
79699                 if (!node.initializer)
79700                     return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType));
79701                 return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker));
79702             }
79703             return cleanup(resolver.createReturnTypeOfSignatureDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker));
79704             function cleanup(returnValue) {
79705                 errorNameNode = undefined;
79706                 if (!suppressNewDiagnosticContexts) {
79707                     getSymbolAccessibilityDiagnostic = oldDiag;
79708                 }
79709                 return returnValue || factory.createKeywordTypeNode(128);
79710             }
79711         }
79712         function isDeclarationAndNotVisible(node) {
79713             node = ts.getParseTreeNode(node);
79714             switch (node.kind) {
79715                 case 251:
79716                 case 256:
79717                 case 253:
79718                 case 252:
79719                 case 254:
79720                 case 255:
79721                     return !resolver.isDeclarationVisible(node);
79722                 case 249:
79723                     return !getBindingNameVisible(node);
79724                 case 260:
79725                 case 261:
79726                 case 267:
79727                 case 266:
79728                     return false;
79729             }
79730             return false;
79731         }
79732         function getBindingNameVisible(elem) {
79733             if (ts.isOmittedExpression(elem)) {
79734                 return false;
79735             }
79736             if (ts.isBindingPattern(elem.name)) {
79737                 return ts.some(elem.name.elements, getBindingNameVisible);
79738             }
79739             else {
79740                 return resolver.isDeclarationVisible(elem);
79741             }
79742         }
79743         function updateParamsList(node, params, modifierMask) {
79744             if (ts.hasEffectiveModifier(node, 8)) {
79745                 return undefined;
79746             }
79747             var newParams = ts.map(params, function (p) { return ensureParameter(p, modifierMask); });
79748             if (!newParams) {
79749                 return undefined;
79750             }
79751             return factory.createNodeArray(newParams, params.hasTrailingComma);
79752         }
79753         function updateAccessorParamsList(input, isPrivate) {
79754             var newParams;
79755             if (!isPrivate) {
79756                 var thisParameter = ts.getThisParameter(input);
79757                 if (thisParameter) {
79758                     newParams = [ensureParameter(thisParameter)];
79759                 }
79760             }
79761             if (ts.isSetAccessorDeclaration(input)) {
79762                 var newValueParameter = void 0;
79763                 if (!isPrivate) {
79764                     var valueParameter = ts.getSetAccessorValueParameter(input);
79765                     if (valueParameter) {
79766                         var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input));
79767                         newValueParameter = ensureParameter(valueParameter, undefined, accessorType);
79768                     }
79769                 }
79770                 if (!newValueParameter) {
79771                     newValueParameter = factory.createParameterDeclaration(undefined, undefined, undefined, "value");
79772                 }
79773                 newParams = ts.append(newParams, newValueParameter);
79774             }
79775             return factory.createNodeArray(newParams || ts.emptyArray);
79776         }
79777         function ensureTypeParams(node, params) {
79778             return ts.hasEffectiveModifier(node, 8) ? undefined : ts.visitNodes(params, visitDeclarationSubtree);
79779         }
79780         function isEnclosingDeclaration(node) {
79781             return ts.isSourceFile(node)
79782                 || ts.isTypeAliasDeclaration(node)
79783                 || ts.isModuleDeclaration(node)
79784                 || ts.isClassDeclaration(node)
79785                 || ts.isInterfaceDeclaration(node)
79786                 || ts.isFunctionLike(node)
79787                 || ts.isIndexSignatureDeclaration(node)
79788                 || ts.isMappedTypeNode(node);
79789         }
79790         function checkEntityNameVisibility(entityName, enclosingDeclaration) {
79791             var visibilityResult = resolver.isEntityNameVisible(entityName, enclosingDeclaration);
79792             handleSymbolAccessibilityError(visibilityResult);
79793             recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName));
79794         }
79795         function preserveJsDoc(updated, original) {
79796             if (ts.hasJSDocNodes(updated) && ts.hasJSDocNodes(original)) {
79797                 updated.jsDoc = original.jsDoc;
79798             }
79799             return ts.setCommentRange(updated, ts.getCommentRange(original));
79800         }
79801         function rewriteModuleSpecifier(parent, input) {
79802             if (!input)
79803                 return undefined;
79804             resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 256 && parent.kind !== 195);
79805             if (ts.isStringLiteralLike(input)) {
79806                 if (isBundledEmit) {
79807                     var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent);
79808                     if (newName) {
79809                         return factory.createStringLiteral(newName);
79810                     }
79811                 }
79812                 else {
79813                     var symbol = resolver.getSymbolOfExternalModuleSpecifier(input);
79814                     if (symbol) {
79815                         (exportedModulesFromDeclarationEmit || (exportedModulesFromDeclarationEmit = [])).push(symbol);
79816                     }
79817                 }
79818             }
79819             return input;
79820         }
79821         function transformImportEqualsDeclaration(decl) {
79822             if (!resolver.isDeclarationVisible(decl))
79823                 return;
79824             if (decl.moduleReference.kind === 272) {
79825                 var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl);
79826                 return factory.updateImportEqualsDeclaration(decl, undefined, decl.modifiers, decl.name, factory.updateExternalModuleReference(decl.moduleReference, rewriteModuleSpecifier(decl, specifier)));
79827             }
79828             else {
79829                 var oldDiag = getSymbolAccessibilityDiagnostic;
79830                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(decl);
79831                 checkEntityNameVisibility(decl.moduleReference, enclosingDeclaration);
79832                 getSymbolAccessibilityDiagnostic = oldDiag;
79833                 return decl;
79834             }
79835         }
79836         function transformImportDeclaration(decl) {
79837             if (!decl.importClause) {
79838                 return factory.updateImportDeclaration(decl, undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier));
79839             }
79840             var visibleDefaultBinding = decl.importClause && decl.importClause.name && resolver.isDeclarationVisible(decl.importClause) ? decl.importClause.name : undefined;
79841             if (!decl.importClause.namedBindings) {
79842                 return visibleDefaultBinding && factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier));
79843             }
79844             if (decl.importClause.namedBindings.kind === 263) {
79845                 var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : undefined;
79846                 return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined;
79847             }
79848             var bindingList = ts.mapDefined(decl.importClause.namedBindings.elements, function (b) { return resolver.isDeclarationVisible(b) ? b : undefined; });
79849             if ((bindingList && bindingList.length) || visibleDefaultBinding) {
79850                 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));
79851             }
79852             if (resolver.isImportRequiredByAugmentation(decl)) {
79853                 return factory.updateImportDeclaration(decl, undefined, decl.modifiers, undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier));
79854             }
79855         }
79856         function transformAndReplaceLatePaintedStatements(statements) {
79857             while (ts.length(lateMarkedStatements)) {
79858                 var i = lateMarkedStatements.shift();
79859                 if (!ts.isLateVisibilityPaintedStatement(i)) {
79860                     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));
79861                 }
79862                 var priorNeedsDeclare = needsDeclare;
79863                 needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit);
79864                 var result = transformTopLevelDeclaration(i);
79865                 needsDeclare = priorNeedsDeclare;
79866                 lateStatementReplacementMap.set(ts.getOriginalNodeId(i), result);
79867             }
79868             return ts.visitNodes(statements, visitLateVisibilityMarkedStatements);
79869             function visitLateVisibilityMarkedStatements(statement) {
79870                 if (ts.isLateVisibilityPaintedStatement(statement)) {
79871                     var key = ts.getOriginalNodeId(statement);
79872                     if (lateStatementReplacementMap.has(key)) {
79873                         var result = lateStatementReplacementMap.get(key);
79874                         lateStatementReplacementMap.delete(key);
79875                         if (result) {
79876                             if (ts.isArray(result) ? ts.some(result, ts.needsScopeMarker) : ts.needsScopeMarker(result)) {
79877                                 needsScopeFixMarker = true;
79878                             }
79879                             if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, ts.isExternalModuleIndicator) : ts.isExternalModuleIndicator(result))) {
79880                                 resultHasExternalModuleIndicator = true;
79881                             }
79882                         }
79883                         return result;
79884                     }
79885                 }
79886                 return statement;
79887             }
79888         }
79889         function visitDeclarationSubtree(input) {
79890             if (shouldStripInternal(input))
79891                 return;
79892             if (ts.isDeclaration(input)) {
79893                 if (isDeclarationAndNotVisible(input))
79894                     return;
79895                 if (ts.hasDynamicName(input) && !resolver.isLateBound(ts.getParseTreeNode(input))) {
79896                     return;
79897                 }
79898             }
79899             if (ts.isFunctionLike(input) && resolver.isImplementationOfOverload(input))
79900                 return;
79901             if (ts.isSemicolonClassElement(input))
79902                 return;
79903             var previousEnclosingDeclaration;
79904             if (isEnclosingDeclaration(input)) {
79905                 previousEnclosingDeclaration = enclosingDeclaration;
79906                 enclosingDeclaration = input;
79907             }
79908             var oldDiag = getSymbolAccessibilityDiagnostic;
79909             var canProduceDiagnostic = ts.canProduceDiagnostics(input);
79910             var oldWithinObjectLiteralType = suppressNewDiagnosticContexts;
79911             var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 177 || input.kind === 190) && input.parent.kind !== 254);
79912             if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) {
79913                 if (ts.hasEffectiveModifier(input, 8)) {
79914                     if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input)
79915                         return;
79916                     return cleanup(factory.createPropertyDeclaration(undefined, ensureModifiers(input), input.name, undefined, undefined, undefined));
79917                 }
79918             }
79919             if (canProduceDiagnostic && !suppressNewDiagnosticContexts) {
79920                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input);
79921             }
79922             if (ts.isTypeQueryNode(input)) {
79923                 checkEntityNameVisibility(input.exprName, enclosingDeclaration);
79924             }
79925             if (shouldEnterSuppressNewDiagnosticsContextContext) {
79926                 suppressNewDiagnosticContexts = true;
79927             }
79928             if (isProcessedComponent(input)) {
79929                 switch (input.kind) {
79930                     case 223: {
79931                         if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) {
79932                             checkEntityNameVisibility(input.expression, enclosingDeclaration);
79933                         }
79934                         var node = ts.visitEachChild(input, visitDeclarationSubtree, context);
79935                         return cleanup(factory.updateExpressionWithTypeArguments(node, node.expression, node.typeArguments));
79936                     }
79937                     case 173: {
79938                         checkEntityNameVisibility(input.typeName, enclosingDeclaration);
79939                         var node = ts.visitEachChild(input, visitDeclarationSubtree, context);
79940                         return cleanup(factory.updateTypeReferenceNode(node, node.typeName, node.typeArguments));
79941                     }
79942                     case 170:
79943                         return cleanup(factory.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)));
79944                     case 166: {
79945                         var ctor = factory.createConstructorDeclaration(undefined, ensureModifiers(input), updateParamsList(input, input.parameters, 0), undefined);
79946                         return cleanup(ctor);
79947                     }
79948                     case 165: {
79949                         if (ts.isPrivateIdentifier(input.name)) {
79950                             return cleanup(undefined);
79951                         }
79952                         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);
79953                         return cleanup(sig);
79954                     }
79955                     case 167: {
79956                         if (ts.isPrivateIdentifier(input.name)) {
79957                             return cleanup(undefined);
79958                         }
79959                         var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input));
79960                         return cleanup(factory.updateGetAccessorDeclaration(input, undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8)), ensureType(input, accessorType), undefined));
79961                     }
79962                     case 168: {
79963                         if (ts.isPrivateIdentifier(input.name)) {
79964                             return cleanup(undefined);
79965                         }
79966                         return cleanup(factory.updateSetAccessorDeclaration(input, undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8)), undefined));
79967                     }
79968                     case 163:
79969                         if (ts.isPrivateIdentifier(input.name)) {
79970                             return cleanup(undefined);
79971                         }
79972                         return cleanup(factory.updatePropertyDeclaration(input, undefined, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input)));
79973                     case 162:
79974                         if (ts.isPrivateIdentifier(input.name)) {
79975                             return cleanup(undefined);
79976                         }
79977                         return cleanup(factory.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type)));
79978                     case 164: {
79979                         if (ts.isPrivateIdentifier(input.name)) {
79980                             return cleanup(undefined);
79981                         }
79982                         return cleanup(factory.updateMethodSignature(input, ensureModifiers(input), input.name, input.questionToken, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)));
79983                     }
79984                     case 169: {
79985                         return cleanup(factory.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)));
79986                     }
79987                     case 171: {
79988                         return cleanup(factory.updateIndexSignature(input, undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(128)));
79989                     }
79990                     case 249: {
79991                         if (ts.isBindingPattern(input.name)) {
79992                             return recreateBindingPattern(input.name);
79993                         }
79994                         shouldEnterSuppressNewDiagnosticsContextContext = true;
79995                         suppressNewDiagnosticContexts = true;
79996                         return cleanup(factory.updateVariableDeclaration(input, input.name, undefined, ensureType(input, input.type), ensureNoInitializer(input)));
79997                     }
79998                     case 159: {
79999                         if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) {
80000                             return cleanup(factory.updateTypeParameterDeclaration(input, input.name, undefined, undefined));
80001                         }
80002                         return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context));
80003                     }
80004                     case 184: {
80005                         var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree);
80006                         var extendsType = ts.visitNode(input.extendsType, visitDeclarationSubtree);
80007                         var oldEnclosingDecl = enclosingDeclaration;
80008                         enclosingDeclaration = input.trueType;
80009                         var trueType = ts.visitNode(input.trueType, visitDeclarationSubtree);
80010                         enclosingDeclaration = oldEnclosingDecl;
80011                         var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree);
80012                         return cleanup(factory.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType));
80013                     }
80014                     case 174: {
80015                         return cleanup(factory.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree)));
80016                     }
80017                     case 175: {
80018                         return cleanup(factory.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree)));
80019                     }
80020                     case 195: {
80021                         if (!ts.isLiteralImportTypeNode(input))
80022                             return cleanup(input);
80023                         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));
80024                     }
80025                     default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.SyntaxKind[input.kind]);
80026                 }
80027             }
80028             if (ts.isTupleTypeNode(input) && (ts.getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === ts.getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) {
80029                 ts.setEmitFlags(input, 1);
80030             }
80031             return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context));
80032             function cleanup(returnValue) {
80033                 if (returnValue && canProduceDiagnostic && ts.hasDynamicName(input)) {
80034                     checkName(input);
80035                 }
80036                 if (isEnclosingDeclaration(input)) {
80037                     enclosingDeclaration = previousEnclosingDeclaration;
80038                 }
80039                 if (canProduceDiagnostic && !suppressNewDiagnosticContexts) {
80040                     getSymbolAccessibilityDiagnostic = oldDiag;
80041                 }
80042                 if (shouldEnterSuppressNewDiagnosticsContextContext) {
80043                     suppressNewDiagnosticContexts = oldWithinObjectLiteralType;
80044                 }
80045                 if (returnValue === input) {
80046                     return returnValue;
80047                 }
80048                 return returnValue && ts.setOriginalNode(preserveJsDoc(returnValue, input), input);
80049             }
80050         }
80051         function isPrivateMethodTypeParameter(node) {
80052             return node.parent.kind === 165 && ts.hasEffectiveModifier(node.parent, 8);
80053         }
80054         function visitDeclarationStatements(input) {
80055             if (!isPreservedDeclarationStatement(input)) {
80056                 return;
80057             }
80058             if (shouldStripInternal(input))
80059                 return;
80060             switch (input.kind) {
80061                 case 267: {
80062                     if (ts.isSourceFile(input.parent)) {
80063                         resultHasExternalModuleIndicator = true;
80064                     }
80065                     resultHasScopeMarker = true;
80066                     return factory.updateExportDeclaration(input, undefined, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier));
80067                 }
80068                 case 266: {
80069                     if (ts.isSourceFile(input.parent)) {
80070                         resultHasExternalModuleIndicator = true;
80071                     }
80072                     resultHasScopeMarker = true;
80073                     if (input.expression.kind === 78) {
80074                         return input;
80075                     }
80076                     else {
80077                         var newId = factory.createUniqueName("_default", 16);
80078                         getSymbolAccessibilityDiagnostic = function () { return ({
80079                             diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0,
80080                             errorNode: input
80081                         }); };
80082                         var varDecl = factory.createVariableDeclaration(newId, undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), undefined);
80083                         var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(133)] : [], factory.createVariableDeclarationList([varDecl], 2));
80084                         return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)];
80085                     }
80086                 }
80087             }
80088             var result = transformTopLevelDeclaration(input);
80089             lateStatementReplacementMap.set(ts.getOriginalNodeId(input), result);
80090             return input;
80091         }
80092         function stripExportModifiers(statement) {
80093             if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512) || !ts.canHaveModifiers(statement)) {
80094                 return statement;
80095             }
80096             var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (11263 ^ 1));
80097             return factory.updateModifiers(statement, modifiers);
80098         }
80099         function transformTopLevelDeclaration(input) {
80100             if (shouldStripInternal(input))
80101                 return;
80102             switch (input.kind) {
80103                 case 260: {
80104                     return transformImportEqualsDeclaration(input);
80105                 }
80106                 case 261: {
80107                     return transformImportDeclaration(input);
80108                 }
80109             }
80110             if (ts.isDeclaration(input) && isDeclarationAndNotVisible(input))
80111                 return;
80112             if (ts.isFunctionLike(input) && resolver.isImplementationOfOverload(input))
80113                 return;
80114             var previousEnclosingDeclaration;
80115             if (isEnclosingDeclaration(input)) {
80116                 previousEnclosingDeclaration = enclosingDeclaration;
80117                 enclosingDeclaration = input;
80118             }
80119             var canProdiceDiagnostic = ts.canProduceDiagnostics(input);
80120             var oldDiag = getSymbolAccessibilityDiagnostic;
80121             if (canProdiceDiagnostic) {
80122                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input);
80123             }
80124             var previousNeedsDeclare = needsDeclare;
80125             switch (input.kind) {
80126                 case 254:
80127                     return cleanup(factory.updateTypeAliasDeclaration(input, undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode)));
80128                 case 253: {
80129                     return cleanup(factory.updateInterfaceDeclaration(input, undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree)));
80130                 }
80131                 case 251: {
80132                     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));
80133                     if (clean && resolver.isExpandoFunctionDeclaration(input)) {
80134                         var props = resolver.getPropertiesOfContainerFunction(input);
80135                         var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(undefined, undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16);
80136                         ts.setParent(fakespace_1, enclosingDeclaration);
80137                         fakespace_1.locals = ts.createSymbolTable(props);
80138                         fakespace_1.symbol = props[0].parent;
80139                         var exportMappings_1 = [];
80140                         var declarations = ts.mapDefined(props, function (p) {
80141                             if (!ts.isPropertyAccessExpression(p.valueDeclaration)) {
80142                                 return undefined;
80143                             }
80144                             getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration);
80145                             var type = resolver.createTypeOfDeclaration(p.valueDeclaration, fakespace_1, declarationEmitNodeBuilderFlags, symbolTracker);
80146                             getSymbolAccessibilityDiagnostic = oldDiag;
80147                             var nameStr = ts.unescapeLeadingUnderscores(p.escapedName);
80148                             var isNonContextualKeywordName = ts.isStringANonContextualKeyword(nameStr);
80149                             var name = isNonContextualKeywordName ? factory.getGeneratedNameForNode(p.valueDeclaration) : factory.createIdentifier(nameStr);
80150                             if (isNonContextualKeywordName) {
80151                                 exportMappings_1.push([name, nameStr]);
80152                             }
80153                             var varDecl = factory.createVariableDeclaration(name, undefined, type, undefined);
80154                             return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(92)], factory.createVariableDeclarationList([varDecl]));
80155                         });
80156                         if (!exportMappings_1.length) {
80157                             declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0); });
80158                         }
80159                         else {
80160                             declarations.push(factory.createExportDeclaration(undefined, undefined, false, factory.createNamedExports(ts.map(exportMappings_1, function (_a) {
80161                                 var gen = _a[0], exp = _a[1];
80162                                 return factory.createExportSpecifier(gen, exp);
80163                             }))));
80164                         }
80165                         var namespaceDecl = factory.createModuleDeclaration(undefined, ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16);
80166                         if (!ts.hasEffectiveModifier(clean, 512)) {
80167                             return [clean, namespaceDecl];
80168                         }
80169                         var modifiers = factory.createModifiersFromModifierFlags((ts.getEffectiveModifierFlags(clean) & ~513) | 2);
80170                         var cleanDeclaration = factory.updateFunctionDeclaration(clean, undefined, modifiers, undefined, clean.name, clean.typeParameters, clean.parameters, clean.type, undefined);
80171                         var namespaceDeclaration = factory.updateModuleDeclaration(namespaceDecl, undefined, modifiers, namespaceDecl.name, namespaceDecl.body);
80172                         var exportDefaultDeclaration = factory.createExportAssignment(undefined, undefined, false, namespaceDecl.name);
80173                         if (ts.isSourceFile(input.parent)) {
80174                             resultHasExternalModuleIndicator = true;
80175                         }
80176                         resultHasScopeMarker = true;
80177                         return [cleanDeclaration, namespaceDeclaration, exportDefaultDeclaration];
80178                     }
80179                     else {
80180                         return clean;
80181                     }
80182                 }
80183                 case 256: {
80184                     needsDeclare = false;
80185                     var inner = input.body;
80186                     if (inner && inner.kind === 257) {
80187                         var oldNeedsScopeFix = needsScopeFixMarker;
80188                         var oldHasScopeFix = resultHasScopeMarker;
80189                         resultHasScopeMarker = false;
80190                         needsScopeFixMarker = false;
80191                         var statements = ts.visitNodes(inner.statements, visitDeclarationStatements);
80192                         var lateStatements = transformAndReplaceLatePaintedStatements(statements);
80193                         if (input.flags & 8388608) {
80194                             needsScopeFixMarker = false;
80195                         }
80196                         if (!ts.isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) {
80197                             if (needsScopeFixMarker) {
80198                                 lateStatements = factory.createNodeArray(__spreadArrays(lateStatements, [ts.createEmptyExports(factory)]));
80199                             }
80200                             else {
80201                                 lateStatements = ts.visitNodes(lateStatements, stripExportModifiers);
80202                             }
80203                         }
80204                         var body = factory.updateModuleBlock(inner, lateStatements);
80205                         needsDeclare = previousNeedsDeclare;
80206                         needsScopeFixMarker = oldNeedsScopeFix;
80207                         resultHasScopeMarker = oldHasScopeFix;
80208                         var mods = ensureModifiers(input);
80209                         return cleanup(factory.updateModuleDeclaration(input, undefined, mods, ts.isExternalModuleAugmentation(input) ? rewriteModuleSpecifier(input, input.name) : input.name, body));
80210                     }
80211                     else {
80212                         needsDeclare = previousNeedsDeclare;
80213                         var mods = ensureModifiers(input);
80214                         needsDeclare = false;
80215                         ts.visitNode(inner, visitDeclarationStatements);
80216                         var id = ts.getOriginalNodeId(inner);
80217                         var body = lateStatementReplacementMap.get(id);
80218                         lateStatementReplacementMap.delete(id);
80219                         return cleanup(factory.updateModuleDeclaration(input, undefined, mods, input.name, body));
80220                     }
80221                 }
80222                 case 252: {
80223                     var modifiers = factory.createNodeArray(ensureModifiers(input));
80224                     var typeParameters = ensureTypeParams(input, input.typeParameters);
80225                     var ctor = ts.getFirstConstructorWithBody(input);
80226                     var parameterProperties = void 0;
80227                     if (ctor) {
80228                         var oldDiag_1 = getSymbolAccessibilityDiagnostic;
80229                         parameterProperties = ts.compact(ts.flatMap(ctor.parameters, function (param) {
80230                             if (!ts.hasSyntacticModifier(param, 92) || shouldStripInternal(param))
80231                                 return;
80232                             getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param);
80233                             if (param.name.kind === 78) {
80234                                 return preserveJsDoc(factory.createPropertyDeclaration(undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param);
80235                             }
80236                             else {
80237                                 return walkBindingPattern(param.name);
80238                             }
80239                             function walkBindingPattern(pattern) {
80240                                 var elems;
80241                                 for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
80242                                     var elem = _a[_i];
80243                                     if (ts.isOmittedExpression(elem))
80244                                         continue;
80245                                     if (ts.isBindingPattern(elem.name)) {
80246                                         elems = ts.concatenate(elems, walkBindingPattern(elem.name));
80247                                     }
80248                                     elems = elems || [];
80249                                     elems.push(factory.createPropertyDeclaration(undefined, ensureModifiers(param), elem.name, undefined, ensureType(elem, undefined), undefined));
80250                                 }
80251                                 return elems;
80252                             }
80253                         }));
80254                         getSymbolAccessibilityDiagnostic = oldDiag_1;
80255                     }
80256                     var hasPrivateIdentifier = ts.some(input.members, function (member) { return !!member.name && ts.isPrivateIdentifier(member.name); });
80257                     var privateIdentifier = hasPrivateIdentifier ? [
80258                         factory.createPropertyDeclaration(undefined, undefined, factory.createPrivateIdentifier("#private"), undefined, undefined, undefined)
80259                     ] : undefined;
80260                     var memberNodes = ts.concatenate(ts.concatenate(privateIdentifier, parameterProperties), ts.visitNodes(input.members, visitDeclarationSubtree));
80261                     var members = factory.createNodeArray(memberNodes);
80262                     var extendsClause_1 = ts.getEffectiveBaseTypeNode(input);
80263                     if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 103) {
80264                         var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default";
80265                         var newId_1 = factory.createUniqueName(oldId + "_base", 16);
80266                         getSymbolAccessibilityDiagnostic = function () { return ({
80267                             diagnosticMessage: ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1,
80268                             errorNode: extendsClause_1,
80269                             typeName: input.name
80270                         }); };
80271                         var varDecl = factory.createVariableDeclaration(newId_1, undefined, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), undefined);
80272                         var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(133)] : [], factory.createVariableDeclarationList([varDecl], 2));
80273                         var heritageClauses = factory.createNodeArray(ts.map(input.heritageClauses, function (clause) {
80274                             if (clause.token === 93) {
80275                                 var oldDiag_2 = getSymbolAccessibilityDiagnostic;
80276                                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]);
80277                                 var newClause = factory.updateHeritageClause(clause, ts.map(clause.types, function (t) { return factory.updateExpressionWithTypeArguments(t, newId_1, ts.visitNodes(t.typeArguments, visitDeclarationSubtree)); }));
80278                                 getSymbolAccessibilityDiagnostic = oldDiag_2;
80279                                 return newClause;
80280                             }
80281                             return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 103; })), visitDeclarationSubtree));
80282                         }));
80283                         return [statement, cleanup(factory.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members))];
80284                     }
80285                     else {
80286                         var heritageClauses = transformHeritageClauses(input.heritageClauses);
80287                         return cleanup(factory.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members));
80288                     }
80289                 }
80290                 case 232: {
80291                     return cleanup(transformVariableStatement(input));
80292                 }
80293                 case 255: {
80294                     return cleanup(factory.updateEnumDeclaration(input, undefined, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(ts.mapDefined(input.members, function (m) {
80295                         if (shouldStripInternal(m))
80296                             return;
80297                         var constValue = resolver.getConstantValue(m);
80298                         return preserveJsDoc(factory.updateEnumMember(m, m.name, constValue !== undefined ? typeof constValue === "string" ? factory.createStringLiteral(constValue) : factory.createNumericLiteral(constValue) : undefined), m);
80299                     }))));
80300                 }
80301             }
80302             return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.SyntaxKind[input.kind]);
80303             function cleanup(node) {
80304                 if (isEnclosingDeclaration(input)) {
80305                     enclosingDeclaration = previousEnclosingDeclaration;
80306                 }
80307                 if (canProdiceDiagnostic) {
80308                     getSymbolAccessibilityDiagnostic = oldDiag;
80309                 }
80310                 if (input.kind === 256) {
80311                     needsDeclare = previousNeedsDeclare;
80312                 }
80313                 if (node === input) {
80314                     return node;
80315                 }
80316                 return node && ts.setOriginalNode(preserveJsDoc(node, input), input);
80317             }
80318         }
80319         function transformVariableStatement(input) {
80320             if (!ts.forEach(input.declarationList.declarations, getBindingNameVisible))
80321                 return;
80322             var nodes = ts.visitNodes(input.declarationList.declarations, visitDeclarationSubtree);
80323             if (!ts.length(nodes))
80324                 return;
80325             return factory.updateVariableStatement(input, factory.createNodeArray(ensureModifiers(input)), factory.updateVariableDeclarationList(input.declarationList, nodes));
80326         }
80327         function recreateBindingPattern(d) {
80328             return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); }));
80329         }
80330         function recreateBindingElement(e) {
80331             if (e.kind === 222) {
80332                 return;
80333             }
80334             if (e.name) {
80335                 if (!getBindingNameVisible(e))
80336                     return;
80337                 if (ts.isBindingPattern(e.name)) {
80338                     return recreateBindingPattern(e.name);
80339                 }
80340                 else {
80341                     return factory.createVariableDeclaration(e.name, undefined, ensureType(e, undefined), undefined);
80342                 }
80343             }
80344         }
80345         function checkName(node) {
80346             var oldDiag;
80347             if (!suppressNewDiagnosticContexts) {
80348                 oldDiag = getSymbolAccessibilityDiagnostic;
80349                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNodeName(node);
80350             }
80351             errorNameNode = node.name;
80352             ts.Debug.assert(resolver.isLateBound(ts.getParseTreeNode(node)));
80353             var decl = node;
80354             var entityName = decl.name.expression;
80355             checkEntityNameVisibility(entityName, enclosingDeclaration);
80356             if (!suppressNewDiagnosticContexts) {
80357                 getSymbolAccessibilityDiagnostic = oldDiag;
80358             }
80359             errorNameNode = undefined;
80360         }
80361         function shouldStripInternal(node) {
80362             return !!stripInternal && !!node && isInternalDeclaration(node, currentSourceFile);
80363         }
80364         function isScopeMarker(node) {
80365             return ts.isExportAssignment(node) || ts.isExportDeclaration(node);
80366         }
80367         function hasScopeMarker(statements) {
80368             return ts.some(statements, isScopeMarker);
80369         }
80370         function ensureModifiers(node) {
80371             var currentFlags = ts.getEffectiveModifierFlags(node);
80372             var newFlags = ensureModifierFlags(node);
80373             if (currentFlags === newFlags) {
80374                 return node.modifiers;
80375             }
80376             return factory.createModifiersFromModifierFlags(newFlags);
80377         }
80378         function ensureModifierFlags(node) {
80379             var mask = 11263 ^ (4 | 256);
80380             var additions = (needsDeclare && !isAlwaysType(node)) ? 2 : 0;
80381             var parentIsFile = node.parent.kind === 297;
80382             if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) {
80383                 mask ^= 2;
80384                 additions = 0;
80385             }
80386             return maskModifierFlags(node, mask, additions);
80387         }
80388         function getTypeAnnotationFromAllAccessorDeclarations(node, accessors) {
80389             var accessorType = getTypeAnnotationFromAccessor(node);
80390             if (!accessorType && node !== accessors.firstAccessor) {
80391                 accessorType = getTypeAnnotationFromAccessor(accessors.firstAccessor);
80392                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.firstAccessor);
80393             }
80394             if (!accessorType && accessors.secondAccessor && node !== accessors.secondAccessor) {
80395                 accessorType = getTypeAnnotationFromAccessor(accessors.secondAccessor);
80396                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.secondAccessor);
80397             }
80398             return accessorType;
80399         }
80400         function transformHeritageClauses(nodes) {
80401             return factory.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) {
80402                 return ts.isEntityNameExpression(t.expression) || (clause.token === 93 && t.expression.kind === 103);
80403             })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; }));
80404         }
80405     }
80406     ts.transformDeclarations = transformDeclarations;
80407     function isAlwaysType(node) {
80408         if (node.kind === 253) {
80409             return true;
80410         }
80411         return false;
80412     }
80413     function maskModifiers(node, modifierMask, modifierAdditions) {
80414         return ts.factory.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions));
80415     }
80416     function maskModifierFlags(node, modifierMask, modifierAdditions) {
80417         if (modifierMask === void 0) { modifierMask = 11263 ^ 4; }
80418         if (modifierAdditions === void 0) { modifierAdditions = 0; }
80419         var flags = (ts.getEffectiveModifierFlags(node) & modifierMask) | modifierAdditions;
80420         if (flags & 512 && !(flags & 1)) {
80421             flags ^= 1;
80422         }
80423         if (flags & 512 && flags & 2) {
80424             flags ^= 2;
80425         }
80426         return flags;
80427     }
80428     function getTypeAnnotationFromAccessor(accessor) {
80429         if (accessor) {
80430             return accessor.kind === 167
80431                 ? accessor.type
80432                 : accessor.parameters.length > 0
80433                     ? accessor.parameters[0].type
80434                     : undefined;
80435         }
80436     }
80437     function canHaveLiteralInitializer(node) {
80438         switch (node.kind) {
80439             case 163:
80440             case 162:
80441                 return !ts.hasEffectiveModifier(node, 8);
80442             case 160:
80443             case 249:
80444                 return true;
80445         }
80446         return false;
80447     }
80448     function isPreservedDeclarationStatement(node) {
80449         switch (node.kind) {
80450             case 251:
80451             case 256:
80452             case 260:
80453             case 253:
80454             case 252:
80455             case 254:
80456             case 255:
80457             case 232:
80458             case 261:
80459             case 267:
80460             case 266:
80461                 return true;
80462         }
80463         return false;
80464     }
80465     function isProcessedComponent(node) {
80466         switch (node.kind) {
80467             case 170:
80468             case 166:
80469             case 165:
80470             case 167:
80471             case 168:
80472             case 163:
80473             case 162:
80474             case 164:
80475             case 169:
80476             case 171:
80477             case 249:
80478             case 159:
80479             case 223:
80480             case 173:
80481             case 184:
80482             case 174:
80483             case 175:
80484             case 195:
80485                 return true;
80486         }
80487         return false;
80488     }
80489 })(ts || (ts = {}));
80490 var ts;
80491 (function (ts) {
80492     function getModuleTransformer(moduleKind) {
80493         switch (moduleKind) {
80494             case ts.ModuleKind.ESNext:
80495             case ts.ModuleKind.ES2020:
80496             case ts.ModuleKind.ES2015:
80497                 return ts.transformECMAScriptModule;
80498             case ts.ModuleKind.System:
80499                 return ts.transformSystemModule;
80500             default:
80501                 return ts.transformModule;
80502         }
80503     }
80504     ts.noTransformers = { scriptTransformers: ts.emptyArray, declarationTransformers: ts.emptyArray };
80505     function getTransformers(compilerOptions, customTransformers, emitOnlyDtsFiles) {
80506         return {
80507             scriptTransformers: getScriptTransformers(compilerOptions, customTransformers, emitOnlyDtsFiles),
80508             declarationTransformers: getDeclarationTransformers(customTransformers),
80509         };
80510     }
80511     ts.getTransformers = getTransformers;
80512     function getScriptTransformers(compilerOptions, customTransformers, emitOnlyDtsFiles) {
80513         if (emitOnlyDtsFiles)
80514             return ts.emptyArray;
80515         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
80516         var moduleKind = ts.getEmitModuleKind(compilerOptions);
80517         var transformers = [];
80518         ts.addRange(transformers, customTransformers && ts.map(customTransformers.before, wrapScriptTransformerFactory));
80519         transformers.push(ts.transformTypeScript);
80520         transformers.push(ts.transformClassFields);
80521         if (ts.getJSXTransformEnabled(compilerOptions)) {
80522             transformers.push(ts.transformJsx);
80523         }
80524         if (languageVersion < 99) {
80525             transformers.push(ts.transformESNext);
80526         }
80527         if (languageVersion < 7) {
80528             transformers.push(ts.transformES2020);
80529         }
80530         if (languageVersion < 6) {
80531             transformers.push(ts.transformES2019);
80532         }
80533         if (languageVersion < 5) {
80534             transformers.push(ts.transformES2018);
80535         }
80536         if (languageVersion < 4) {
80537             transformers.push(ts.transformES2017);
80538         }
80539         if (languageVersion < 3) {
80540             transformers.push(ts.transformES2016);
80541         }
80542         if (languageVersion < 2) {
80543             transformers.push(ts.transformES2015);
80544             transformers.push(ts.transformGenerators);
80545         }
80546         transformers.push(getModuleTransformer(moduleKind));
80547         if (languageVersion < 1) {
80548             transformers.push(ts.transformES5);
80549         }
80550         ts.addRange(transformers, customTransformers && ts.map(customTransformers.after, wrapScriptTransformerFactory));
80551         return transformers;
80552     }
80553     function getDeclarationTransformers(customTransformers) {
80554         var transformers = [];
80555         transformers.push(ts.transformDeclarations);
80556         ts.addRange(transformers, customTransformers && ts.map(customTransformers.afterDeclarations, wrapDeclarationTransformerFactory));
80557         return transformers;
80558     }
80559     function wrapCustomTransformer(transformer) {
80560         return function (node) { return ts.isBundle(node) ? transformer.transformBundle(node) : transformer.transformSourceFile(node); };
80561     }
80562     function wrapCustomTransformerFactory(transformer, handleDefault) {
80563         return function (context) {
80564             var customTransformer = transformer(context);
80565             return typeof customTransformer === "function"
80566                 ? handleDefault(context, customTransformer)
80567                 : wrapCustomTransformer(customTransformer);
80568         };
80569     }
80570     function wrapScriptTransformerFactory(transformer) {
80571         return wrapCustomTransformerFactory(transformer, ts.chainBundle);
80572     }
80573     function wrapDeclarationTransformerFactory(transformer) {
80574         return wrapCustomTransformerFactory(transformer, function (_, node) { return node; });
80575     }
80576     function noEmitSubstitution(_hint, node) {
80577         return node;
80578     }
80579     ts.noEmitSubstitution = noEmitSubstitution;
80580     function noEmitNotification(hint, node, callback) {
80581         callback(hint, node);
80582     }
80583     ts.noEmitNotification = noEmitNotification;
80584     function transformNodes(resolver, host, factory, options, nodes, transformers, allowDtsFiles) {
80585         var enabledSyntaxKindFeatures = new Array(341);
80586         var lexicalEnvironmentVariableDeclarations;
80587         var lexicalEnvironmentFunctionDeclarations;
80588         var lexicalEnvironmentStatements;
80589         var lexicalEnvironmentFlags = 0;
80590         var lexicalEnvironmentVariableDeclarationsStack = [];
80591         var lexicalEnvironmentFunctionDeclarationsStack = [];
80592         var lexicalEnvironmentStatementsStack = [];
80593         var lexicalEnvironmentFlagsStack = [];
80594         var lexicalEnvironmentStackOffset = 0;
80595         var lexicalEnvironmentSuspended = false;
80596         var emitHelpers;
80597         var onSubstituteNode = noEmitSubstitution;
80598         var onEmitNode = noEmitNotification;
80599         var state = 0;
80600         var diagnostics = [];
80601         var context = {
80602             factory: factory,
80603             getCompilerOptions: function () { return options; },
80604             getEmitResolver: function () { return resolver; },
80605             getEmitHost: function () { return host; },
80606             getEmitHelperFactory: ts.memoize(function () { return ts.createEmitHelperFactory(context); }),
80607             startLexicalEnvironment: startLexicalEnvironment,
80608             suspendLexicalEnvironment: suspendLexicalEnvironment,
80609             resumeLexicalEnvironment: resumeLexicalEnvironment,
80610             endLexicalEnvironment: endLexicalEnvironment,
80611             setLexicalEnvironmentFlags: setLexicalEnvironmentFlags,
80612             getLexicalEnvironmentFlags: getLexicalEnvironmentFlags,
80613             hoistVariableDeclaration: hoistVariableDeclaration,
80614             hoistFunctionDeclaration: hoistFunctionDeclaration,
80615             addInitializationStatement: addInitializationStatement,
80616             requestEmitHelper: requestEmitHelper,
80617             readEmitHelpers: readEmitHelpers,
80618             enableSubstitution: enableSubstitution,
80619             enableEmitNotification: enableEmitNotification,
80620             isSubstitutionEnabled: isSubstitutionEnabled,
80621             isEmitNotificationEnabled: isEmitNotificationEnabled,
80622             get onSubstituteNode() { return onSubstituteNode; },
80623             set onSubstituteNode(value) {
80624                 ts.Debug.assert(state < 1, "Cannot modify transformation hooks after initialization has completed.");
80625                 ts.Debug.assert(value !== undefined, "Value must not be 'undefined'");
80626                 onSubstituteNode = value;
80627             },
80628             get onEmitNode() { return onEmitNode; },
80629             set onEmitNode(value) {
80630                 ts.Debug.assert(state < 1, "Cannot modify transformation hooks after initialization has completed.");
80631                 ts.Debug.assert(value !== undefined, "Value must not be 'undefined'");
80632                 onEmitNode = value;
80633             },
80634             addDiagnostic: function (diag) {
80635                 diagnostics.push(diag);
80636             }
80637         };
80638         for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) {
80639             var node = nodes_2[_i];
80640             ts.disposeEmitNodes(ts.getSourceFileOfNode(ts.getParseTreeNode(node)));
80641         }
80642         ts.performance.mark("beforeTransform");
80643         var transformersWithContext = transformers.map(function (t) { return t(context); });
80644         var transformation = function (node) {
80645             for (var _i = 0, transformersWithContext_1 = transformersWithContext; _i < transformersWithContext_1.length; _i++) {
80646                 var transform = transformersWithContext_1[_i];
80647                 node = transform(node);
80648             }
80649             return node;
80650         };
80651         state = 1;
80652         var transformed = [];
80653         for (var _a = 0, nodes_3 = nodes; _a < nodes_3.length; _a++) {
80654             var node = nodes_3[_a];
80655             ts.tracing.push("emit", "transformNodes", node.kind === 297 ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end });
80656             transformed.push((allowDtsFiles ? transformation : transformRoot)(node));
80657             ts.tracing.pop();
80658         }
80659         state = 2;
80660         ts.performance.mark("afterTransform");
80661         ts.performance.measure("transformTime", "beforeTransform", "afterTransform");
80662         return {
80663             transformed: transformed,
80664             substituteNode: substituteNode,
80665             emitNodeWithNotification: emitNodeWithNotification,
80666             isEmitNotificationEnabled: isEmitNotificationEnabled,
80667             dispose: dispose,
80668             diagnostics: diagnostics
80669         };
80670         function transformRoot(node) {
80671             return node && (!ts.isSourceFile(node) || !node.isDeclarationFile) ? transformation(node) : node;
80672         }
80673         function enableSubstitution(kind) {
80674             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
80675             enabledSyntaxKindFeatures[kind] |= 1;
80676         }
80677         function isSubstitutionEnabled(node) {
80678             return (enabledSyntaxKindFeatures[node.kind] & 1) !== 0
80679                 && (ts.getEmitFlags(node) & 4) === 0;
80680         }
80681         function substituteNode(hint, node) {
80682             ts.Debug.assert(state < 3, "Cannot substitute a node after the result is disposed.");
80683             return node && isSubstitutionEnabled(node) && onSubstituteNode(hint, node) || node;
80684         }
80685         function enableEmitNotification(kind) {
80686             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
80687             enabledSyntaxKindFeatures[kind] |= 2;
80688         }
80689         function isEmitNotificationEnabled(node) {
80690             return (enabledSyntaxKindFeatures[node.kind] & 2) !== 0
80691                 || (ts.getEmitFlags(node) & 2) !== 0;
80692         }
80693         function emitNodeWithNotification(hint, node, emitCallback) {
80694             ts.Debug.assert(state < 3, "Cannot invoke TransformationResult callbacks after the result is disposed.");
80695             if (node) {
80696                 if (isEmitNotificationEnabled(node)) {
80697                     onEmitNode(hint, node, emitCallback);
80698                 }
80699                 else {
80700                     emitCallback(hint, node);
80701                 }
80702             }
80703         }
80704         function hoistVariableDeclaration(name) {
80705             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
80706             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
80707             var decl = ts.setEmitFlags(factory.createVariableDeclaration(name), 64);
80708             if (!lexicalEnvironmentVariableDeclarations) {
80709                 lexicalEnvironmentVariableDeclarations = [decl];
80710             }
80711             else {
80712                 lexicalEnvironmentVariableDeclarations.push(decl);
80713             }
80714             if (lexicalEnvironmentFlags & 1) {
80715                 lexicalEnvironmentFlags |= 2;
80716             }
80717         }
80718         function hoistFunctionDeclaration(func) {
80719             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
80720             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
80721             ts.setEmitFlags(func, 1048576);
80722             if (!lexicalEnvironmentFunctionDeclarations) {
80723                 lexicalEnvironmentFunctionDeclarations = [func];
80724             }
80725             else {
80726                 lexicalEnvironmentFunctionDeclarations.push(func);
80727             }
80728         }
80729         function addInitializationStatement(node) {
80730             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
80731             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
80732             ts.setEmitFlags(node, 1048576);
80733             if (!lexicalEnvironmentStatements) {
80734                 lexicalEnvironmentStatements = [node];
80735             }
80736             else {
80737                 lexicalEnvironmentStatements.push(node);
80738             }
80739         }
80740         function startLexicalEnvironment() {
80741             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
80742             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
80743             ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended.");
80744             lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentVariableDeclarations;
80745             lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFunctionDeclarations;
80746             lexicalEnvironmentStatementsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentStatements;
80747             lexicalEnvironmentFlagsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFlags;
80748             lexicalEnvironmentStackOffset++;
80749             lexicalEnvironmentVariableDeclarations = undefined;
80750             lexicalEnvironmentFunctionDeclarations = undefined;
80751             lexicalEnvironmentStatements = undefined;
80752             lexicalEnvironmentFlags = 0;
80753         }
80754         function suspendLexicalEnvironment() {
80755             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
80756             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
80757             ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended.");
80758             lexicalEnvironmentSuspended = true;
80759         }
80760         function resumeLexicalEnvironment() {
80761             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
80762             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
80763             ts.Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended.");
80764             lexicalEnvironmentSuspended = false;
80765         }
80766         function endLexicalEnvironment() {
80767             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
80768             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
80769             ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended.");
80770             var statements;
80771             if (lexicalEnvironmentVariableDeclarations ||
80772                 lexicalEnvironmentFunctionDeclarations ||
80773                 lexicalEnvironmentStatements) {
80774                 if (lexicalEnvironmentFunctionDeclarations) {
80775                     statements = __spreadArrays(lexicalEnvironmentFunctionDeclarations);
80776                 }
80777                 if (lexicalEnvironmentVariableDeclarations) {
80778                     var statement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList(lexicalEnvironmentVariableDeclarations));
80779                     ts.setEmitFlags(statement, 1048576);
80780                     if (!statements) {
80781                         statements = [statement];
80782                     }
80783                     else {
80784                         statements.push(statement);
80785                     }
80786                 }
80787                 if (lexicalEnvironmentStatements) {
80788                     if (!statements) {
80789                         statements = __spreadArrays(lexicalEnvironmentStatements);
80790                     }
80791                     else {
80792                         statements = __spreadArrays(statements, lexicalEnvironmentStatements);
80793                     }
80794                 }
80795             }
80796             lexicalEnvironmentStackOffset--;
80797             lexicalEnvironmentVariableDeclarations = lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset];
80798             lexicalEnvironmentFunctionDeclarations = lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset];
80799             lexicalEnvironmentStatements = lexicalEnvironmentStatementsStack[lexicalEnvironmentStackOffset];
80800             lexicalEnvironmentFlags = lexicalEnvironmentFlagsStack[lexicalEnvironmentStackOffset];
80801             if (lexicalEnvironmentStackOffset === 0) {
80802                 lexicalEnvironmentVariableDeclarationsStack = [];
80803                 lexicalEnvironmentFunctionDeclarationsStack = [];
80804                 lexicalEnvironmentStatementsStack = [];
80805                 lexicalEnvironmentFlagsStack = [];
80806             }
80807             return statements;
80808         }
80809         function setLexicalEnvironmentFlags(flags, value) {
80810             lexicalEnvironmentFlags = value ?
80811                 lexicalEnvironmentFlags | flags :
80812                 lexicalEnvironmentFlags & ~flags;
80813         }
80814         function getLexicalEnvironmentFlags() {
80815             return lexicalEnvironmentFlags;
80816         }
80817         function requestEmitHelper(helper) {
80818             ts.Debug.assert(state > 0, "Cannot modify the transformation context during initialization.");
80819             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
80820             ts.Debug.assert(!helper.scoped, "Cannot request a scoped emit helper.");
80821             if (helper.dependencies) {
80822                 for (var _i = 0, _a = helper.dependencies; _i < _a.length; _i++) {
80823                     var h = _a[_i];
80824                     requestEmitHelper(h);
80825                 }
80826             }
80827             emitHelpers = ts.append(emitHelpers, helper);
80828         }
80829         function readEmitHelpers() {
80830             ts.Debug.assert(state > 0, "Cannot modify the transformation context during initialization.");
80831             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
80832             var helpers = emitHelpers;
80833             emitHelpers = undefined;
80834             return helpers;
80835         }
80836         function dispose() {
80837             if (state < 3) {
80838                 for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) {
80839                     var node = nodes_4[_i];
80840                     ts.disposeEmitNodes(ts.getSourceFileOfNode(ts.getParseTreeNode(node)));
80841                 }
80842                 lexicalEnvironmentVariableDeclarations = undefined;
80843                 lexicalEnvironmentVariableDeclarationsStack = undefined;
80844                 lexicalEnvironmentFunctionDeclarations = undefined;
80845                 lexicalEnvironmentFunctionDeclarationsStack = undefined;
80846                 onSubstituteNode = undefined;
80847                 onEmitNode = undefined;
80848                 emitHelpers = undefined;
80849                 state = 3;
80850             }
80851         }
80852     }
80853     ts.transformNodes = transformNodes;
80854     ts.nullTransformationContext = {
80855         get factory() { return ts.factory; },
80856         enableEmitNotification: ts.noop,
80857         enableSubstitution: ts.noop,
80858         endLexicalEnvironment: ts.returnUndefined,
80859         getCompilerOptions: function () { return ({}); },
80860         getEmitHost: ts.notImplemented,
80861         getEmitResolver: ts.notImplemented,
80862         getEmitHelperFactory: ts.notImplemented,
80863         setLexicalEnvironmentFlags: ts.noop,
80864         getLexicalEnvironmentFlags: function () { return 0; },
80865         hoistFunctionDeclaration: ts.noop,
80866         hoistVariableDeclaration: ts.noop,
80867         addInitializationStatement: ts.noop,
80868         isEmitNotificationEnabled: ts.notImplemented,
80869         isSubstitutionEnabled: ts.notImplemented,
80870         onEmitNode: ts.noop,
80871         onSubstituteNode: ts.notImplemented,
80872         readEmitHelpers: ts.notImplemented,
80873         requestEmitHelper: ts.noop,
80874         resumeLexicalEnvironment: ts.noop,
80875         startLexicalEnvironment: ts.noop,
80876         suspendLexicalEnvironment: ts.noop,
80877         addDiagnostic: ts.noop,
80878     };
80879 })(ts || (ts = {}));
80880 var ts;
80881 (function (ts) {
80882     var brackets = createBracketsMap();
80883     var syntheticParent = { pos: -1, end: -1 };
80884     function isBuildInfoFile(file) {
80885         return ts.fileExtensionIs(file, ".tsbuildinfo");
80886     }
80887     ts.isBuildInfoFile = isBuildInfoFile;
80888     function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) {
80889         if (forceDtsEmit === void 0) { forceDtsEmit = false; }
80890         var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile, forceDtsEmit);
80891         var options = host.getCompilerOptions();
80892         if (ts.outFile(options)) {
80893             var prepends = host.getPrependNodes();
80894             if (sourceFiles.length || prepends.length) {
80895                 var bundle = ts.factory.createBundle(sourceFiles, prepends);
80896                 var result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle);
80897                 if (result) {
80898                     return result;
80899                 }
80900             }
80901         }
80902         else {
80903             if (!onlyBuildInfo) {
80904                 for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) {
80905                     var sourceFile = sourceFiles_1[_a];
80906                     var result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile);
80907                     if (result) {
80908                         return result;
80909                     }
80910                 }
80911             }
80912             if (includeBuildInfo) {
80913                 var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options);
80914                 if (buildInfoPath)
80915                     return action({ buildInfoPath: buildInfoPath }, undefined);
80916             }
80917         }
80918     }
80919     ts.forEachEmittedFile = forEachEmittedFile;
80920     function getTsBuildInfoEmitOutputFilePath(options) {
80921         var configFile = options.configFilePath;
80922         if (!ts.isIncrementalCompilation(options))
80923             return undefined;
80924         if (options.tsBuildInfoFile)
80925             return options.tsBuildInfoFile;
80926         var outPath = ts.outFile(options);
80927         var buildInfoExtensionLess;
80928         if (outPath) {
80929             buildInfoExtensionLess = ts.removeFileExtension(outPath);
80930         }
80931         else {
80932             if (!configFile)
80933                 return undefined;
80934             var configFileExtensionLess = ts.removeFileExtension(configFile);
80935             buildInfoExtensionLess = options.outDir ?
80936                 options.rootDir ?
80937                     ts.resolvePath(options.outDir, ts.getRelativePathFromDirectory(options.rootDir, configFileExtensionLess, true)) :
80938                     ts.combinePaths(options.outDir, ts.getBaseFileName(configFileExtensionLess)) :
80939                 configFileExtensionLess;
80940         }
80941         return buildInfoExtensionLess + ".tsbuildinfo";
80942     }
80943     ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath;
80944     function getOutputPathsForBundle(options, forceDtsPaths) {
80945         var outPath = ts.outFile(options);
80946         var jsFilePath = options.emitDeclarationOnly ? undefined : outPath;
80947         var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options);
80948         var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" : undefined;
80949         var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined;
80950         var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options);
80951         return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath };
80952     }
80953     ts.getOutputPathsForBundle = getOutputPathsForBundle;
80954     function getOutputPathsFor(sourceFile, host, forceDtsPaths) {
80955         var options = host.getCompilerOptions();
80956         if (sourceFile.kind === 298) {
80957             return getOutputPathsForBundle(options, forceDtsPaths);
80958         }
80959         else {
80960             var ownOutputFilePath = ts.getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile, options));
80961             var isJsonFile = ts.isJsonSourceFile(sourceFile);
80962             var isJsonEmittedToSameLocation = isJsonFile &&
80963                 ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0;
80964             var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath;
80965             var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options);
80966             var declarationFilePath = (forceDtsPaths || (ts.getEmitDeclarations(options) && !isJsonFile)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined;
80967             var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined;
80968             return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined };
80969         }
80970     }
80971     ts.getOutputPathsFor = getOutputPathsFor;
80972     function getSourceMapFilePath(jsFilePath, options) {
80973         return (options.sourceMap && !options.inlineSourceMap) ? jsFilePath + ".map" : undefined;
80974     }
80975     function getOutputExtension(sourceFile, options) {
80976         if (ts.isJsonSourceFile(sourceFile)) {
80977             return ".json";
80978         }
80979         if (options.jsx === 1) {
80980             if (ts.isSourceFileJS(sourceFile)) {
80981                 if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) {
80982                     return ".jsx";
80983                 }
80984             }
80985             else if (sourceFile.languageVariant === 1) {
80986                 return ".jsx";
80987             }
80988         }
80989         return ".js";
80990     }
80991     ts.getOutputExtension = getOutputExtension;
80992     function rootDirOfOptions(configFile) {
80993         return configFile.options.rootDir || ts.getDirectoryPath(ts.Debug.checkDefined(configFile.options.configFilePath));
80994     }
80995     function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir) {
80996         return outputDir ?
80997             ts.resolvePath(outputDir, ts.getRelativePathFromDirectory(rootDirOfOptions(configFile), inputFileName, ignoreCase)) :
80998             inputFileName;
80999     }
81000     function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) {
81001         ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts") && !ts.fileExtensionIs(inputFileName, ".json"));
81002         return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts");
81003     }
81004     ts.getOutputDeclarationFileName = getOutputDeclarationFileName;
81005     function getOutputJSFileName(inputFileName, configFile, ignoreCase) {
81006         if (configFile.options.emitDeclarationOnly)
81007             return undefined;
81008         var isJsonFile = ts.fileExtensionIs(inputFileName, ".json");
81009         var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir), isJsonFile ?
81010             ".json" :
81011             ts.fileExtensionIs(inputFileName, ".tsx") && configFile.options.jsx === 1 ?
81012                 ".jsx" :
81013                 ".js");
81014         return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 ?
81015             outputFileName :
81016             undefined;
81017     }
81018     function createAddOutput() {
81019         var outputs;
81020         return { addOutput: addOutput, getOutputs: getOutputs };
81021         function addOutput(path) {
81022             if (path) {
81023                 (outputs || (outputs = [])).push(path);
81024             }
81025         }
81026         function getOutputs() {
81027             return outputs || ts.emptyArray;
81028         }
81029     }
81030     function getSingleOutputFileNames(configFile, addOutput) {
81031         var _a = getOutputPathsForBundle(configFile.options, false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
81032         addOutput(jsFilePath);
81033         addOutput(sourceMapFilePath);
81034         addOutput(declarationFilePath);
81035         addOutput(declarationMapPath);
81036         addOutput(buildInfoPath);
81037     }
81038     function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput) {
81039         if (ts.fileExtensionIs(inputFileName, ".d.ts"))
81040             return;
81041         var js = getOutputJSFileName(inputFileName, configFile, ignoreCase);
81042         addOutput(js);
81043         if (ts.fileExtensionIs(inputFileName, ".json"))
81044             return;
81045         if (js && configFile.options.sourceMap) {
81046             addOutput(js + ".map");
81047         }
81048         if (ts.getEmitDeclarations(configFile.options)) {
81049             var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase);
81050             addOutput(dts);
81051             if (configFile.options.declarationMap) {
81052                 addOutput(dts + ".map");
81053             }
81054         }
81055     }
81056     function getAllProjectOutputs(configFile, ignoreCase) {
81057         var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs;
81058         if (ts.outFile(configFile.options)) {
81059             getSingleOutputFileNames(configFile, addOutput);
81060         }
81061         else {
81062             for (var _b = 0, _c = configFile.fileNames; _b < _c.length; _b++) {
81063                 var inputFileName = _c[_b];
81064                 getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput);
81065             }
81066             addOutput(getTsBuildInfoEmitOutputFilePath(configFile.options));
81067         }
81068         return getOutputs();
81069     }
81070     ts.getAllProjectOutputs = getAllProjectOutputs;
81071     function getOutputFileNames(commandLine, inputFileName, ignoreCase) {
81072         inputFileName = ts.normalizePath(inputFileName);
81073         ts.Debug.assert(ts.contains(commandLine.fileNames, inputFileName), "Expected fileName to be present in command line");
81074         var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs;
81075         if (ts.outFile(commandLine.options)) {
81076             getSingleOutputFileNames(commandLine, addOutput);
81077         }
81078         else {
81079             getOwnOutputFileNames(commandLine, inputFileName, ignoreCase, addOutput);
81080         }
81081         return getOutputs();
81082     }
81083     ts.getOutputFileNames = getOutputFileNames;
81084     function getFirstProjectOutput(configFile, ignoreCase) {
81085         if (ts.outFile(configFile.options)) {
81086             var jsFilePath = getOutputPathsForBundle(configFile.options, false).jsFilePath;
81087             return ts.Debug.checkDefined(jsFilePath, "project " + configFile.options.configFilePath + " expected to have at least one output");
81088         }
81089         for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) {
81090             var inputFileName = _b[_a];
81091             if (ts.fileExtensionIs(inputFileName, ".d.ts"))
81092                 continue;
81093             var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase);
81094             if (jsFilePath)
81095                 return jsFilePath;
81096             if (ts.fileExtensionIs(inputFileName, ".json"))
81097                 continue;
81098             if (ts.getEmitDeclarations(configFile.options)) {
81099                 return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase);
81100             }
81101         }
81102         var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options);
81103         if (buildInfoPath)
81104             return buildInfoPath;
81105         return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output");
81106     }
81107     ts.getFirstProjectOutput = getFirstProjectOutput;
81108     function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) {
81109         var scriptTransformers = _a.scriptTransformers, declarationTransformers = _a.declarationTransformers;
81110         var compilerOptions = host.getCompilerOptions();
81111         var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined;
81112         var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined;
81113         var emitterDiagnostics = ts.createDiagnosticCollection();
81114         var newLine = ts.getNewLineCharacter(compilerOptions, function () { return host.getNewLine(); });
81115         var writer = ts.createTextWriter(newLine);
81116         var _b = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _b.enter, exit = _b.exit;
81117         var bundleBuildInfo;
81118         var emitSkipped = false;
81119         var exportedModulesFromDeclarationEmit;
81120         enter();
81121         forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit), forceDtsEmit, onlyBuildInfo, !targetSourceFile);
81122         exit();
81123         return {
81124             emitSkipped: emitSkipped,
81125             diagnostics: emitterDiagnostics.getDiagnostics(),
81126             emittedFiles: emittedFilesList,
81127             sourceMaps: sourceMapDataList,
81128             exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit
81129         };
81130         function emitSourceFileOrBundle(_a, sourceFileOrBundle) {
81131             var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
81132             var buildInfoDirectory;
81133             if (buildInfoPath && sourceFileOrBundle && ts.isBundle(sourceFileOrBundle)) {
81134                 buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
81135                 bundleBuildInfo = {
81136                     commonSourceDirectory: relativeToBuildInfo(host.getCommonSourceDirectory()),
81137                     sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); })
81138                 };
81139             }
81140             ts.tracing.push("emit", "emitJsFileOrBundle", { jsFilePath: jsFilePath });
81141             emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo);
81142             ts.tracing.pop();
81143             ts.tracing.push("emit", "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath });
81144             emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo);
81145             ts.tracing.pop();
81146             ts.tracing.push("emit", "emitBuildInfo", { buildInfoPath: buildInfoPath });
81147             emitBuildInfo(bundleBuildInfo, buildInfoPath);
81148             ts.tracing.pop();
81149             if (!emitSkipped && emittedFilesList) {
81150                 if (!emitOnlyDtsFiles) {
81151                     if (jsFilePath) {
81152                         emittedFilesList.push(jsFilePath);
81153                     }
81154                     if (sourceMapFilePath) {
81155                         emittedFilesList.push(sourceMapFilePath);
81156                     }
81157                     if (buildInfoPath) {
81158                         emittedFilesList.push(buildInfoPath);
81159                     }
81160                 }
81161                 if (declarationFilePath) {
81162                     emittedFilesList.push(declarationFilePath);
81163                 }
81164                 if (declarationMapPath) {
81165                     emittedFilesList.push(declarationMapPath);
81166                 }
81167             }
81168             function relativeToBuildInfo(path) {
81169                 return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, host.getCanonicalFileName));
81170             }
81171         }
81172         function emitBuildInfo(bundle, buildInfoPath) {
81173             if (!buildInfoPath || targetSourceFile || emitSkipped)
81174                 return;
81175             var program = host.getProgramBuildInfo();
81176             if (host.isEmitBlocked(buildInfoPath)) {
81177                 emitSkipped = true;
81178                 return;
81179             }
81180             var version = ts.version;
81181             ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText({ bundle: bundle, program: program, version: version }), false);
81182         }
81183         function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo) {
81184             if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) {
81185                 return;
81186             }
81187             if ((jsFilePath && host.isEmitBlocked(jsFilePath)) || compilerOptions.noEmit) {
81188                 emitSkipped = true;
81189                 return;
81190             }
81191             var transform = ts.transformNodes(resolver, host, ts.factory, compilerOptions, [sourceFileOrBundle], scriptTransformers, false);
81192             var printerOptions = {
81193                 removeComments: compilerOptions.removeComments,
81194                 newLine: compilerOptions.newLine,
81195                 noEmitHelpers: compilerOptions.noEmitHelpers,
81196                 module: compilerOptions.module,
81197                 target: compilerOptions.target,
81198                 sourceMap: compilerOptions.sourceMap,
81199                 inlineSourceMap: compilerOptions.inlineSourceMap,
81200                 inlineSources: compilerOptions.inlineSources,
81201                 extendedDiagnostics: compilerOptions.extendedDiagnostics,
81202                 writeBundleFileInfo: !!bundleBuildInfo,
81203                 relativeToBuildInfo: relativeToBuildInfo
81204             };
81205             var printer = createPrinter(printerOptions, {
81206                 hasGlobalName: resolver.hasGlobalName,
81207                 onEmitNode: transform.emitNodeWithNotification,
81208                 isEmitNotificationEnabled: transform.isEmitNotificationEnabled,
81209                 substituteNode: transform.substituteNode,
81210             });
81211             ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform");
81212             printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], printer, compilerOptions);
81213             transform.dispose();
81214             if (bundleBuildInfo)
81215                 bundleBuildInfo.js = printer.bundleFileInfo;
81216         }
81217         function emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo) {
81218             if (!sourceFileOrBundle)
81219                 return;
81220             if (!declarationFilePath) {
81221                 if (emitOnlyDtsFiles || compilerOptions.emitDeclarationOnly)
81222                     emitSkipped = true;
81223                 return;
81224             }
81225             var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles;
81226             var filesForEmit = forceDtsEmit ? sourceFiles : ts.filter(sourceFiles, ts.isSourceFileNotJson);
81227             var inputListOrBundle = ts.outFile(compilerOptions) ? [ts.factory.createBundle(filesForEmit, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : filesForEmit;
81228             if (emitOnlyDtsFiles && !ts.getEmitDeclarations(compilerOptions)) {
81229                 filesForEmit.forEach(collectLinkedAliases);
81230             }
81231             var declarationTransform = ts.transformNodes(resolver, host, ts.factory, compilerOptions, inputListOrBundle, declarationTransformers, false);
81232             if (ts.length(declarationTransform.diagnostics)) {
81233                 for (var _a = 0, _b = declarationTransform.diagnostics; _a < _b.length; _a++) {
81234                     var diagnostic = _b[_a];
81235                     emitterDiagnostics.add(diagnostic);
81236                 }
81237             }
81238             var printerOptions = {
81239                 removeComments: compilerOptions.removeComments,
81240                 newLine: compilerOptions.newLine,
81241                 noEmitHelpers: true,
81242                 module: compilerOptions.module,
81243                 target: compilerOptions.target,
81244                 sourceMap: compilerOptions.sourceMap,
81245                 inlineSourceMap: compilerOptions.inlineSourceMap,
81246                 extendedDiagnostics: compilerOptions.extendedDiagnostics,
81247                 onlyPrintJsDocStyle: true,
81248                 writeBundleFileInfo: !!bundleBuildInfo,
81249                 recordInternalSection: !!bundleBuildInfo,
81250                 relativeToBuildInfo: relativeToBuildInfo
81251             };
81252             var declarationPrinter = createPrinter(printerOptions, {
81253                 hasGlobalName: resolver.hasGlobalName,
81254                 onEmitNode: declarationTransform.emitNodeWithNotification,
81255                 isEmitNotificationEnabled: declarationTransform.isEmitNotificationEnabled,
81256                 substituteNode: declarationTransform.substituteNode,
81257             });
81258             var declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit;
81259             emitSkipped = emitSkipped || declBlocked;
81260             if (!declBlocked || forceDtsEmit) {
81261                 ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform");
81262                 printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, {
81263                     sourceMap: compilerOptions.declarationMap,
81264                     sourceRoot: compilerOptions.sourceRoot,
81265                     mapRoot: compilerOptions.mapRoot,
81266                     extendedDiagnostics: compilerOptions.extendedDiagnostics,
81267                 });
81268                 if (forceDtsEmit && declarationTransform.transformed[0].kind === 297) {
81269                     var sourceFile = declarationTransform.transformed[0];
81270                     exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit;
81271                 }
81272             }
81273             declarationTransform.dispose();
81274             if (bundleBuildInfo)
81275                 bundleBuildInfo.dts = declarationPrinter.bundleFileInfo;
81276         }
81277         function collectLinkedAliases(node) {
81278             if (ts.isExportAssignment(node)) {
81279                 if (node.expression.kind === 78) {
81280                     resolver.collectLinkedAliases(node.expression, true);
81281                 }
81282                 return;
81283             }
81284             else if (ts.isExportSpecifier(node)) {
81285                 resolver.collectLinkedAliases(node.propertyName || node.name, true);
81286                 return;
81287             }
81288             ts.forEachChild(node, collectLinkedAliases);
81289         }
81290         function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) {
81291             var bundle = sourceFileOrBundle.kind === 298 ? sourceFileOrBundle : undefined;
81292             var sourceFile = sourceFileOrBundle.kind === 297 ? sourceFileOrBundle : undefined;
81293             var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile];
81294             var sourceMapGenerator;
81295             if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) {
81296                 sourceMapGenerator = ts.createSourceMapGenerator(host, ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)), getSourceRoot(mapOptions), getSourceMapDirectory(mapOptions, jsFilePath, sourceFile), mapOptions);
81297             }
81298             if (bundle) {
81299                 printer.writeBundle(bundle, writer, sourceMapGenerator);
81300             }
81301             else {
81302                 printer.writeFile(sourceFile, writer, sourceMapGenerator);
81303             }
81304             if (sourceMapGenerator) {
81305                 if (sourceMapDataList) {
81306                     sourceMapDataList.push({
81307                         inputSourceFileNames: sourceMapGenerator.getSources(),
81308                         sourceMap: sourceMapGenerator.toJSON()
81309                     });
81310                 }
81311                 var sourceMappingURL = getSourceMappingURL(mapOptions, sourceMapGenerator, jsFilePath, sourceMapFilePath, sourceFile);
81312                 if (sourceMappingURL) {
81313                     if (!writer.isAtStartOfLine())
81314                         writer.rawWrite(newLine);
81315                     writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL);
81316                 }
81317                 if (sourceMapFilePath) {
81318                     var sourceMap = sourceMapGenerator.toString();
81319                     ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, false, sourceFiles);
81320                 }
81321             }
81322             else {
81323                 writer.writeLine();
81324             }
81325             ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles);
81326             writer.clear();
81327         }
81328         function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) {
81329             return (mapOptions.sourceMap || mapOptions.inlineSourceMap)
81330                 && (sourceFileOrBundle.kind !== 297 || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json"));
81331         }
81332         function getSourceRoot(mapOptions) {
81333             var sourceRoot = ts.normalizeSlashes(mapOptions.sourceRoot || "");
81334             return sourceRoot ? ts.ensureTrailingDirectorySeparator(sourceRoot) : sourceRoot;
81335         }
81336         function getSourceMapDirectory(mapOptions, filePath, sourceFile) {
81337             if (mapOptions.sourceRoot)
81338                 return host.getCommonSourceDirectory();
81339             if (mapOptions.mapRoot) {
81340                 var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot);
81341                 if (sourceFile) {
81342                     sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFile.fileName, host, sourceMapDir));
81343                 }
81344                 if (ts.getRootLength(sourceMapDir) === 0) {
81345                     sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir);
81346                 }
81347                 return sourceMapDir;
81348             }
81349             return ts.getDirectoryPath(ts.normalizePath(filePath));
81350         }
81351         function getSourceMappingURL(mapOptions, sourceMapGenerator, filePath, sourceMapFilePath, sourceFile) {
81352             if (mapOptions.inlineSourceMap) {
81353                 var sourceMapText = sourceMapGenerator.toString();
81354                 var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText);
81355                 return "data:application/json;base64," + base64SourceMapText;
81356             }
81357             var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.checkDefined(sourceMapFilePath)));
81358             if (mapOptions.mapRoot) {
81359                 var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot);
81360                 if (sourceFile) {
81361                     sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFile.fileName, host, sourceMapDir));
81362                 }
81363                 if (ts.getRootLength(sourceMapDir) === 0) {
81364                     sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir);
81365                     return encodeURI(ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(filePath)), ts.combinePaths(sourceMapDir, sourceMapFile), host.getCurrentDirectory(), host.getCanonicalFileName, true));
81366                 }
81367                 else {
81368                     return encodeURI(ts.combinePaths(sourceMapDir, sourceMapFile));
81369                 }
81370             }
81371             return encodeURI(sourceMapFile);
81372         }
81373     }
81374     ts.emitFiles = emitFiles;
81375     function getBuildInfoText(buildInfo) {
81376         return JSON.stringify(buildInfo, undefined, 2);
81377     }
81378     ts.getBuildInfoText = getBuildInfoText;
81379     function getBuildInfo(buildInfoText) {
81380         return JSON.parse(buildInfoText);
81381     }
81382     ts.getBuildInfo = getBuildInfo;
81383     ts.notImplementedResolver = {
81384         hasGlobalName: ts.notImplemented,
81385         getReferencedExportContainer: ts.notImplemented,
81386         getReferencedImportDeclaration: ts.notImplemented,
81387         getReferencedDeclarationWithCollidingName: ts.notImplemented,
81388         isDeclarationWithCollidingName: ts.notImplemented,
81389         isValueAliasDeclaration: ts.notImplemented,
81390         isReferencedAliasDeclaration: ts.notImplemented,
81391         isTopLevelValueImportEqualsWithEntityName: ts.notImplemented,
81392         getNodeCheckFlags: ts.notImplemented,
81393         isDeclarationVisible: ts.notImplemented,
81394         isLateBound: function (_node) { return false; },
81395         collectLinkedAliases: ts.notImplemented,
81396         isImplementationOfOverload: ts.notImplemented,
81397         isRequiredInitializedParameter: ts.notImplemented,
81398         isOptionalUninitializedParameterProperty: ts.notImplemented,
81399         isExpandoFunctionDeclaration: ts.notImplemented,
81400         getPropertiesOfContainerFunction: ts.notImplemented,
81401         createTypeOfDeclaration: ts.notImplemented,
81402         createReturnTypeOfSignatureDeclaration: ts.notImplemented,
81403         createTypeOfExpression: ts.notImplemented,
81404         createLiteralConstValue: ts.notImplemented,
81405         isSymbolAccessible: ts.notImplemented,
81406         isEntityNameVisible: ts.notImplemented,
81407         getConstantValue: ts.notImplemented,
81408         getReferencedValueDeclaration: ts.notImplemented,
81409         getTypeReferenceSerializationKind: ts.notImplemented,
81410         isOptionalParameter: ts.notImplemented,
81411         moduleExportsSomeValue: ts.notImplemented,
81412         isArgumentsLocalBinding: ts.notImplemented,
81413         getExternalModuleFileFromDeclaration: ts.notImplemented,
81414         getTypeReferenceDirectivesForEntityName: ts.notImplemented,
81415         getTypeReferenceDirectivesForSymbol: ts.notImplemented,
81416         isLiteralConstDeclaration: ts.notImplemented,
81417         getJsxFactoryEntity: ts.notImplemented,
81418         getJsxFragmentFactoryEntity: ts.notImplemented,
81419         getAllAccessorDeclarations: ts.notImplemented,
81420         getSymbolOfExternalModuleSpecifier: ts.notImplemented,
81421         isBindingCapturedByNode: ts.notImplemented,
81422         getDeclarationStatementsForSourceFile: ts.notImplemented,
81423         isImportRequiredByAugmentation: ts.notImplemented,
81424     };
81425     function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) {
81426         var _a;
81427         var jsBundle = ts.Debug.checkDefined(bundle.js);
81428         var prologueMap = ((_a = jsBundle.sources) === null || _a === void 0 ? void 0 : _a.prologues) && ts.arrayToMap(jsBundle.sources.prologues, function (prologueInfo) { return prologueInfo.file; });
81429         return bundle.sourceFiles.map(function (fileName, index) {
81430             var _a, _b;
81431             var prologueInfo = prologueMap === null || prologueMap === void 0 ? void 0 : prologueMap.get(index);
81432             var statements = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.directives.map(function (directive) {
81433                 var literal = ts.setTextRange(ts.factory.createStringLiteral(directive.expression.text), directive.expression);
81434                 var statement = ts.setTextRange(ts.factory.createExpressionStatement(literal), directive);
81435                 ts.setParent(literal, statement);
81436                 return statement;
81437             });
81438             var eofToken = ts.factory.createToken(1);
81439             var sourceFile = ts.factory.createSourceFile(statements !== null && statements !== void 0 ? statements : [], eofToken, 0);
81440             sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames());
81441             sourceFile.text = (_a = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text) !== null && _a !== void 0 ? _a : "";
81442             ts.setTextRangePosWidth(sourceFile, 0, (_b = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text.length) !== null && _b !== void 0 ? _b : 0);
81443             ts.setEachParent(sourceFile.statements, sourceFile);
81444             ts.setTextRangePosWidth(eofToken, sourceFile.end, 0);
81445             ts.setParent(eofToken, sourceFile);
81446             return sourceFile;
81447         });
81448     }
81449     function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) {
81450         var _a = getOutputPathsForBundle(config.options, false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
81451         var buildInfoText = host.readFile(ts.Debug.checkDefined(buildInfoPath));
81452         if (!buildInfoText)
81453             return buildInfoPath;
81454         var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
81455         if (!jsFileText)
81456             return jsFilePath;
81457         var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
81458         if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
81459             return sourceMapFilePath || "inline sourcemap decoding";
81460         var declarationText = declarationFilePath && host.readFile(declarationFilePath);
81461         if (declarationFilePath && !declarationText)
81462             return declarationFilePath;
81463         var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
81464         if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
81465             return declarationMapPath || "inline sourcemap decoding";
81466         var buildInfo = getBuildInfo(buildInfoText);
81467         if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationText && !buildInfo.bundle.dts))
81468             return buildInfoPath;
81469         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
81470         var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo, true);
81471         var outputFiles = [];
81472         var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); });
81473         var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host);
81474         var emitHost = {
81475             getPrependNodes: ts.memoize(function () { return __spreadArrays(prependNodes, [ownPrependInput]); }),
81476             getCanonicalFileName: host.getCanonicalFileName,
81477             getCommonSourceDirectory: function () { return ts.getNormalizedAbsolutePath(buildInfo.bundle.commonSourceDirectory, buildInfoDirectory); },
81478             getCompilerOptions: function () { return config.options; },
81479             getCurrentDirectory: function () { return host.getCurrentDirectory(); },
81480             getNewLine: function () { return host.getNewLine(); },
81481             getSourceFile: ts.returnUndefined,
81482             getSourceFileByPath: ts.returnUndefined,
81483             getSourceFiles: function () { return sourceFilesForJsEmit; },
81484             getLibFileFromReference: ts.notImplemented,
81485             isSourceFileFromExternalLibrary: ts.returnFalse,
81486             getResolvedProjectReferenceToRedirect: ts.returnUndefined,
81487             getProjectReferenceRedirect: ts.returnUndefined,
81488             isSourceOfProjectReferenceRedirect: ts.returnFalse,
81489             writeFile: function (name, text, writeByteOrderMark) {
81490                 switch (name) {
81491                     case jsFilePath:
81492                         if (jsFileText === text)
81493                             return;
81494                         break;
81495                     case sourceMapFilePath:
81496                         if (sourceMapText === text)
81497                             return;
81498                         break;
81499                     case buildInfoPath:
81500                         var newBuildInfo = getBuildInfo(text);
81501                         newBuildInfo.program = buildInfo.program;
81502                         var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
81503                         newBuildInfo.bundle.js.sources = js.sources;
81504                         if (dts) {
81505                             newBuildInfo.bundle.dts.sources = dts.sources;
81506                         }
81507                         newBuildInfo.bundle.sourceFiles = sourceFiles;
81508                         outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark });
81509                         return;
81510                     case declarationFilePath:
81511                         if (declarationText === text)
81512                             return;
81513                         break;
81514                     case declarationMapPath:
81515                         if (declarationMapText === text)
81516                             return;
81517                         break;
81518                     default:
81519                         ts.Debug.fail("Unexpected path: " + name);
81520                 }
81521                 outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark });
81522             },
81523             isEmitBlocked: ts.returnFalse,
81524             readFile: function (f) { return host.readFile(f); },
81525             fileExists: function (f) { return host.fileExists(f); },
81526             useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
81527             getProgramBuildInfo: ts.returnUndefined,
81528             getSourceFileFromReference: ts.returnUndefined,
81529             redirectTargetsMap: ts.createMultiMap()
81530         };
81531         emitFiles(ts.notImplementedResolver, emitHost, undefined, ts.getTransformers(config.options, customTransformers));
81532         return outputFiles;
81533     }
81534     ts.emitUsingBuildInfo = emitUsingBuildInfo;
81535     function createPrinter(printerOptions, handlers) {
81536         if (printerOptions === void 0) { printerOptions = {}; }
81537         if (handlers === void 0) { handlers = {}; }
81538         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;
81539         var extendedDiagnostics = !!printerOptions.extendedDiagnostics;
81540         var newLine = ts.getNewLineCharacter(printerOptions);
81541         var moduleKind = ts.getEmitModuleKind(printerOptions);
81542         var bundledHelpers = new ts.Map();
81543         var currentSourceFile;
81544         var nodeIdToGeneratedName;
81545         var autoGeneratedIdToGeneratedName;
81546         var generatedNames;
81547         var tempFlagsStack;
81548         var tempFlags;
81549         var reservedNamesStack;
81550         var reservedNames;
81551         var preserveSourceNewlines = printerOptions.preserveSourceNewlines;
81552         var nextListElementPos;
81553         var writer;
81554         var ownWriter;
81555         var write = writeBase;
81556         var isOwnFileEmit;
81557         var bundleFileInfo = printerOptions.writeBundleFileInfo ? { sections: [] } : undefined;
81558         var relativeToBuildInfo = bundleFileInfo ? ts.Debug.checkDefined(printerOptions.relativeToBuildInfo) : undefined;
81559         var recordInternalSection = printerOptions.recordInternalSection;
81560         var sourceFileTextPos = 0;
81561         var sourceFileTextKind = "text";
81562         var sourceMapsDisabled = true;
81563         var sourceMapGenerator;
81564         var sourceMapSource;
81565         var sourceMapSourceIndex = -1;
81566         var mostRecentlyAddedSourceMapSource;
81567         var mostRecentlyAddedSourceMapSourceIndex = -1;
81568         var containerPos = -1;
81569         var containerEnd = -1;
81570         var declarationListContainerEnd = -1;
81571         var currentLineMap;
81572         var detachedCommentsInfo;
81573         var hasWrittenComment = false;
81574         var commentsDisabled = !!printerOptions.removeComments;
81575         var lastNode;
81576         var lastSubstitution;
81577         var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit;
81578         reset();
81579         return {
81580             printNode: printNode,
81581             printList: printList,
81582             printFile: printFile,
81583             printBundle: printBundle,
81584             writeNode: writeNode,
81585             writeList: writeList,
81586             writeFile: writeFile,
81587             writeBundle: writeBundle,
81588             bundleFileInfo: bundleFileInfo
81589         };
81590         function printNode(hint, node, sourceFile) {
81591             switch (hint) {
81592                 case 0:
81593                     ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node.");
81594                     break;
81595                 case 2:
81596                     ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node.");
81597                     break;
81598                 case 1:
81599                     ts.Debug.assert(ts.isExpression(node), "Expected an Expression node.");
81600                     break;
81601             }
81602             switch (node.kind) {
81603                 case 297: return printFile(node);
81604                 case 298: return printBundle(node);
81605                 case 299: return printUnparsedSource(node);
81606             }
81607             writeNode(hint, node, sourceFile, beginPrint());
81608             return endPrint();
81609         }
81610         function printList(format, nodes, sourceFile) {
81611             writeList(format, nodes, sourceFile, beginPrint());
81612             return endPrint();
81613         }
81614         function printBundle(bundle) {
81615             writeBundle(bundle, beginPrint(), undefined);
81616             return endPrint();
81617         }
81618         function printFile(sourceFile) {
81619             writeFile(sourceFile, beginPrint(), undefined);
81620             return endPrint();
81621         }
81622         function printUnparsedSource(unparsed) {
81623             writeUnparsedSource(unparsed, beginPrint());
81624             return endPrint();
81625         }
81626         function writeNode(hint, node, sourceFile, output) {
81627             var previousWriter = writer;
81628             setWriter(output, undefined);
81629             print(hint, node, sourceFile);
81630             reset();
81631             writer = previousWriter;
81632         }
81633         function writeList(format, nodes, sourceFile, output) {
81634             var previousWriter = writer;
81635             setWriter(output, undefined);
81636             if (sourceFile) {
81637                 setSourceFile(sourceFile);
81638             }
81639             emitList(syntheticParent, nodes, format);
81640             reset();
81641             writer = previousWriter;
81642         }
81643         function getTextPosWithWriteLine() {
81644             return writer.getTextPosWithWriteLine ? writer.getTextPosWithWriteLine() : writer.getTextPos();
81645         }
81646         function updateOrPushBundleFileTextLike(pos, end, kind) {
81647             var last = ts.lastOrUndefined(bundleFileInfo.sections);
81648             if (last && last.kind === kind) {
81649                 last.end = end;
81650             }
81651             else {
81652                 bundleFileInfo.sections.push({ pos: pos, end: end, kind: kind });
81653             }
81654         }
81655         function recordBundleFileInternalSectionStart(node) {
81656             if (recordInternalSection &&
81657                 bundleFileInfo &&
81658                 currentSourceFile &&
81659                 (ts.isDeclaration(node) || ts.isVariableStatement(node)) &&
81660                 ts.isInternalDeclaration(node, currentSourceFile) &&
81661                 sourceFileTextKind !== "internal") {
81662                 var prevSourceFileTextKind = sourceFileTextKind;
81663                 recordBundleFileTextLikeSection(writer.getTextPos());
81664                 sourceFileTextPos = getTextPosWithWriteLine();
81665                 sourceFileTextKind = "internal";
81666                 return prevSourceFileTextKind;
81667             }
81668             return undefined;
81669         }
81670         function recordBundleFileInternalSectionEnd(prevSourceFileTextKind) {
81671             if (prevSourceFileTextKind) {
81672                 recordBundleFileTextLikeSection(writer.getTextPos());
81673                 sourceFileTextPos = getTextPosWithWriteLine();
81674                 sourceFileTextKind = prevSourceFileTextKind;
81675             }
81676         }
81677         function recordBundleFileTextLikeSection(end) {
81678             if (sourceFileTextPos < end) {
81679                 updateOrPushBundleFileTextLike(sourceFileTextPos, end, sourceFileTextKind);
81680                 return true;
81681             }
81682             return false;
81683         }
81684         function writeBundle(bundle, output, sourceMapGenerator) {
81685             var _a;
81686             isOwnFileEmit = false;
81687             var previousWriter = writer;
81688             setWriter(output, sourceMapGenerator);
81689             emitShebangIfNeeded(bundle);
81690             emitPrologueDirectivesIfNeeded(bundle);
81691             emitHelpers(bundle);
81692             emitSyntheticTripleSlashReferencesIfNeeded(bundle);
81693             for (var _b = 0, _c = bundle.prepends; _b < _c.length; _b++) {
81694                 var prepend = _c[_b];
81695                 writeLine();
81696                 var pos = writer.getTextPos();
81697                 var savedSections = bundleFileInfo && bundleFileInfo.sections;
81698                 if (savedSections)
81699                     bundleFileInfo.sections = [];
81700                 print(4, prepend, undefined);
81701                 if (bundleFileInfo) {
81702                     var newSections = bundleFileInfo.sections;
81703                     bundleFileInfo.sections = savedSections;
81704                     if (prepend.oldFileOfCurrentEmit)
81705                         (_a = bundleFileInfo.sections).push.apply(_a, newSections);
81706                     else {
81707                         newSections.forEach(function (section) { return ts.Debug.assert(ts.isBundleFileTextLike(section)); });
81708                         bundleFileInfo.sections.push({
81709                             pos: pos,
81710                             end: writer.getTextPos(),
81711                             kind: "prepend",
81712                             data: relativeToBuildInfo(prepend.fileName),
81713                             texts: newSections
81714                         });
81715                     }
81716                 }
81717             }
81718             sourceFileTextPos = getTextPosWithWriteLine();
81719             for (var _d = 0, _e = bundle.sourceFiles; _d < _e.length; _d++) {
81720                 var sourceFile = _e[_d];
81721                 print(0, sourceFile, sourceFile);
81722             }
81723             if (bundleFileInfo && bundle.sourceFiles.length) {
81724                 var end = writer.getTextPos();
81725                 if (recordBundleFileTextLikeSection(end)) {
81726                     var prologues = getPrologueDirectivesFromBundledSourceFiles(bundle);
81727                     if (prologues) {
81728                         if (!bundleFileInfo.sources)
81729                             bundleFileInfo.sources = {};
81730                         bundleFileInfo.sources.prologues = prologues;
81731                     }
81732                     var helpers = getHelpersFromBundledSourceFiles(bundle);
81733                     if (helpers) {
81734                         if (!bundleFileInfo.sources)
81735                             bundleFileInfo.sources = {};
81736                         bundleFileInfo.sources.helpers = helpers;
81737                     }
81738                 }
81739             }
81740             reset();
81741             writer = previousWriter;
81742         }
81743         function writeUnparsedSource(unparsed, output) {
81744             var previousWriter = writer;
81745             setWriter(output, undefined);
81746             print(4, unparsed, undefined);
81747             reset();
81748             writer = previousWriter;
81749         }
81750         function writeFile(sourceFile, output, sourceMapGenerator) {
81751             isOwnFileEmit = true;
81752             var previousWriter = writer;
81753             setWriter(output, sourceMapGenerator);
81754             emitShebangIfNeeded(sourceFile);
81755             emitPrologueDirectivesIfNeeded(sourceFile);
81756             print(0, sourceFile, sourceFile);
81757             reset();
81758             writer = previousWriter;
81759         }
81760         function beginPrint() {
81761             return ownWriter || (ownWriter = ts.createTextWriter(newLine));
81762         }
81763         function endPrint() {
81764             var text = ownWriter.getText();
81765             ownWriter.clear();
81766             return text;
81767         }
81768         function print(hint, node, sourceFile) {
81769             if (sourceFile) {
81770                 setSourceFile(sourceFile);
81771             }
81772             pipelineEmit(hint, node);
81773         }
81774         function setSourceFile(sourceFile) {
81775             currentSourceFile = sourceFile;
81776             currentLineMap = undefined;
81777             detachedCommentsInfo = undefined;
81778             if (sourceFile) {
81779                 setSourceMapSource(sourceFile);
81780             }
81781         }
81782         function setWriter(_writer, _sourceMapGenerator) {
81783             if (_writer && printerOptions.omitTrailingSemicolon) {
81784                 _writer = ts.getTrailingSemicolonDeferringWriter(_writer);
81785             }
81786             writer = _writer;
81787             sourceMapGenerator = _sourceMapGenerator;
81788             sourceMapsDisabled = !writer || !sourceMapGenerator;
81789         }
81790         function reset() {
81791             nodeIdToGeneratedName = [];
81792             autoGeneratedIdToGeneratedName = [];
81793             generatedNames = new ts.Set();
81794             tempFlagsStack = [];
81795             tempFlags = 0;
81796             reservedNamesStack = [];
81797             currentSourceFile = undefined;
81798             currentLineMap = undefined;
81799             detachedCommentsInfo = undefined;
81800             lastNode = undefined;
81801             lastSubstitution = undefined;
81802             setWriter(undefined, undefined);
81803         }
81804         function getCurrentLineMap() {
81805             return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile));
81806         }
81807         function emit(node) {
81808             if (node === undefined)
81809                 return;
81810             var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node);
81811             var substitute = pipelineEmit(4, node);
81812             recordBundleFileInternalSectionEnd(prevSourceFileTextKind);
81813             return substitute;
81814         }
81815         function emitIdentifierName(node) {
81816             if (node === undefined)
81817                 return;
81818             return pipelineEmit(2, node);
81819         }
81820         function emitExpression(node) {
81821             if (node === undefined)
81822                 return;
81823             return pipelineEmit(1, node);
81824         }
81825         function emitJsxAttributeValue(node) {
81826             return pipelineEmit(ts.isStringLiteral(node) ? 6 : 4, node);
81827         }
81828         function pipelineEmit(emitHint, node) {
81829             var savedLastNode = lastNode;
81830             var savedLastSubstitution = lastSubstitution;
81831             var savedPreserveSourceNewlines = preserveSourceNewlines;
81832             lastNode = node;
81833             lastSubstitution = undefined;
81834             if (preserveSourceNewlines && !!(ts.getEmitFlags(node) & 134217728)) {
81835                 preserveSourceNewlines = false;
81836             }
81837             var pipelinePhase = getPipelinePhase(0, emitHint, node);
81838             pipelinePhase(emitHint, node);
81839             ts.Debug.assert(lastNode === node);
81840             var substitute = lastSubstitution;
81841             lastNode = savedLastNode;
81842             lastSubstitution = savedLastSubstitution;
81843             preserveSourceNewlines = savedPreserveSourceNewlines;
81844             return substitute || node;
81845         }
81846         function getPipelinePhase(phase, emitHint, node) {
81847             switch (phase) {
81848                 case 0:
81849                     if (onEmitNode !== ts.noEmitNotification && (!isEmitNotificationEnabled || isEmitNotificationEnabled(node))) {
81850                         return pipelineEmitWithNotification;
81851                     }
81852                 case 1:
81853                     if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node)) !== node) {
81854                         return pipelineEmitWithSubstitution;
81855                     }
81856                 case 2:
81857                     if (!commentsDisabled && node.kind !== 297) {
81858                         return pipelineEmitWithComments;
81859                     }
81860                 case 3:
81861                     if (!sourceMapsDisabled && node.kind !== 297 && !ts.isInJsonFile(node)) {
81862                         return pipelineEmitWithSourceMap;
81863                     }
81864                 case 4:
81865                     return pipelineEmitWithHint;
81866                 default:
81867                     return ts.Debug.assertNever(phase);
81868             }
81869         }
81870         function getNextPipelinePhase(currentPhase, emitHint, node) {
81871             return getPipelinePhase(currentPhase + 1, emitHint, node);
81872         }
81873         function pipelineEmitWithNotification(hint, node) {
81874             ts.Debug.assert(lastNode === node);
81875             var pipelinePhase = getNextPipelinePhase(0, hint, node);
81876             onEmitNode(hint, node, pipelinePhase);
81877             ts.Debug.assert(lastNode === node);
81878         }
81879         function pipelineEmitWithHint(hint, node) {
81880             ts.Debug.assert(lastNode === node || lastSubstitution === node);
81881             if (hint === 0)
81882                 return emitSourceFile(ts.cast(node, ts.isSourceFile));
81883             if (hint === 2)
81884                 return emitIdentifier(ts.cast(node, ts.isIdentifier));
81885             if (hint === 6)
81886                 return emitLiteral(ts.cast(node, ts.isStringLiteral), true);
81887             if (hint === 3)
81888                 return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration));
81889             if (hint === 5) {
81890                 ts.Debug.assertNode(node, ts.isEmptyStatement);
81891                 return emitEmptyStatement(true);
81892             }
81893             if (hint === 4) {
81894                 if (ts.isKeyword(node.kind))
81895                     return writeTokenNode(node, writeKeyword);
81896                 switch (node.kind) {
81897                     case 15:
81898                     case 16:
81899                     case 17:
81900                         return emitLiteral(node, false);
81901                     case 299:
81902                     case 293:
81903                         return emitUnparsedSourceOrPrepend(node);
81904                     case 292:
81905                         return writeUnparsedNode(node);
81906                     case 294:
81907                     case 295:
81908                         return emitUnparsedTextLike(node);
81909                     case 296:
81910                         return emitUnparsedSyntheticReference(node);
81911                     case 78:
81912                         return emitIdentifier(node);
81913                     case 79:
81914                         return emitPrivateIdentifier(node);
81915                     case 157:
81916                         return emitQualifiedName(node);
81917                     case 158:
81918                         return emitComputedPropertyName(node);
81919                     case 159:
81920                         return emitTypeParameter(node);
81921                     case 160:
81922                         return emitParameter(node);
81923                     case 161:
81924                         return emitDecorator(node);
81925                     case 162:
81926                         return emitPropertySignature(node);
81927                     case 163:
81928                         return emitPropertyDeclaration(node);
81929                     case 164:
81930                         return emitMethodSignature(node);
81931                     case 165:
81932                         return emitMethodDeclaration(node);
81933                     case 166:
81934                         return emitConstructor(node);
81935                     case 167:
81936                     case 168:
81937                         return emitAccessorDeclaration(node);
81938                     case 169:
81939                         return emitCallSignature(node);
81940                     case 170:
81941                         return emitConstructSignature(node);
81942                     case 171:
81943                         return emitIndexSignature(node);
81944                     case 194:
81945                         return emitTemplateTypeSpan(node);
81946                     case 172:
81947                         return emitTypePredicate(node);
81948                     case 173:
81949                         return emitTypeReference(node);
81950                     case 174:
81951                         return emitFunctionType(node);
81952                     case 308:
81953                         return emitJSDocFunctionType(node);
81954                     case 175:
81955                         return emitConstructorType(node);
81956                     case 176:
81957                         return emitTypeQuery(node);
81958                     case 177:
81959                         return emitTypeLiteral(node);
81960                     case 178:
81961                         return emitArrayType(node);
81962                     case 179:
81963                         return emitTupleType(node);
81964                     case 180:
81965                         return emitOptionalType(node);
81966                     case 182:
81967                         return emitUnionType(node);
81968                     case 183:
81969                         return emitIntersectionType(node);
81970                     case 184:
81971                         return emitConditionalType(node);
81972                     case 185:
81973                         return emitInferType(node);
81974                     case 186:
81975                         return emitParenthesizedType(node);
81976                     case 223:
81977                         return emitExpressionWithTypeArguments(node);
81978                     case 187:
81979                         return emitThisType();
81980                     case 188:
81981                         return emitTypeOperator(node);
81982                     case 189:
81983                         return emitIndexedAccessType(node);
81984                     case 190:
81985                         return emitMappedType(node);
81986                     case 191:
81987                         return emitLiteralType(node);
81988                     case 193:
81989                         return emitTemplateType(node);
81990                     case 195:
81991                         return emitImportTypeNode(node);
81992                     case 303:
81993                         writePunctuation("*");
81994                         return;
81995                     case 304:
81996                         writePunctuation("?");
81997                         return;
81998                     case 305:
81999                         return emitJSDocNullableType(node);
82000                     case 306:
82001                         return emitJSDocNonNullableType(node);
82002                     case 307:
82003                         return emitJSDocOptionalType(node);
82004                     case 181:
82005                     case 309:
82006                         return emitRestOrJSDocVariadicType(node);
82007                     case 192:
82008                         return emitNamedTupleMember(node);
82009                     case 196:
82010                         return emitObjectBindingPattern(node);
82011                     case 197:
82012                         return emitArrayBindingPattern(node);
82013                     case 198:
82014                         return emitBindingElement(node);
82015                     case 228:
82016                         return emitTemplateSpan(node);
82017                     case 229:
82018                         return emitSemicolonClassElement();
82019                     case 230:
82020                         return emitBlock(node);
82021                     case 232:
82022                         return emitVariableStatement(node);
82023                     case 231:
82024                         return emitEmptyStatement(false);
82025                     case 233:
82026                         return emitExpressionStatement(node);
82027                     case 234:
82028                         return emitIfStatement(node);
82029                     case 235:
82030                         return emitDoStatement(node);
82031                     case 236:
82032                         return emitWhileStatement(node);
82033                     case 237:
82034                         return emitForStatement(node);
82035                     case 238:
82036                         return emitForInStatement(node);
82037                     case 239:
82038                         return emitForOfStatement(node);
82039                     case 240:
82040                         return emitContinueStatement(node);
82041                     case 241:
82042                         return emitBreakStatement(node);
82043                     case 242:
82044                         return emitReturnStatement(node);
82045                     case 243:
82046                         return emitWithStatement(node);
82047                     case 244:
82048                         return emitSwitchStatement(node);
82049                     case 245:
82050                         return emitLabeledStatement(node);
82051                     case 246:
82052                         return emitThrowStatement(node);
82053                     case 247:
82054                         return emitTryStatement(node);
82055                     case 248:
82056                         return emitDebuggerStatement(node);
82057                     case 249:
82058                         return emitVariableDeclaration(node);
82059                     case 250:
82060                         return emitVariableDeclarationList(node);
82061                     case 251:
82062                         return emitFunctionDeclaration(node);
82063                     case 252:
82064                         return emitClassDeclaration(node);
82065                     case 253:
82066                         return emitInterfaceDeclaration(node);
82067                     case 254:
82068                         return emitTypeAliasDeclaration(node);
82069                     case 255:
82070                         return emitEnumDeclaration(node);
82071                     case 256:
82072                         return emitModuleDeclaration(node);
82073                     case 257:
82074                         return emitModuleBlock(node);
82075                     case 258:
82076                         return emitCaseBlock(node);
82077                     case 259:
82078                         return emitNamespaceExportDeclaration(node);
82079                     case 260:
82080                         return emitImportEqualsDeclaration(node);
82081                     case 261:
82082                         return emitImportDeclaration(node);
82083                     case 262:
82084                         return emitImportClause(node);
82085                     case 263:
82086                         return emitNamespaceImport(node);
82087                     case 269:
82088                         return emitNamespaceExport(node);
82089                     case 264:
82090                         return emitNamedImports(node);
82091                     case 265:
82092                         return emitImportSpecifier(node);
82093                     case 266:
82094                         return emitExportAssignment(node);
82095                     case 267:
82096                         return emitExportDeclaration(node);
82097                     case 268:
82098                         return emitNamedExports(node);
82099                     case 270:
82100                         return emitExportSpecifier(node);
82101                     case 271:
82102                         return;
82103                     case 272:
82104                         return emitExternalModuleReference(node);
82105                     case 11:
82106                         return emitJsxText(node);
82107                     case 275:
82108                     case 278:
82109                         return emitJsxOpeningElementOrFragment(node);
82110                     case 276:
82111                     case 279:
82112                         return emitJsxClosingElementOrFragment(node);
82113                     case 280:
82114                         return emitJsxAttribute(node);
82115                     case 281:
82116                         return emitJsxAttributes(node);
82117                     case 282:
82118                         return emitJsxSpreadAttribute(node);
82119                     case 283:
82120                         return emitJsxExpression(node);
82121                     case 284:
82122                         return emitCaseClause(node);
82123                     case 285:
82124                         return emitDefaultClause(node);
82125                     case 286:
82126                         return emitHeritageClause(node);
82127                     case 287:
82128                         return emitCatchClause(node);
82129                     case 288:
82130                         return emitPropertyAssignment(node);
82131                     case 289:
82132                         return emitShorthandPropertyAssignment(node);
82133                     case 290:
82134                         return emitSpreadAssignment(node);
82135                     case 291:
82136                         return emitEnumMember(node);
82137                     case 326:
82138                     case 333:
82139                         return emitJSDocPropertyLikeTag(node);
82140                     case 327:
82141                     case 329:
82142                     case 328:
82143                     case 325:
82144                         return emitJSDocSimpleTypedTag(node);
82145                     case 316:
82146                     case 315:
82147                         return emitJSDocHeritageTag(node);
82148                     case 330:
82149                         return emitJSDocTemplateTag(node);
82150                     case 331:
82151                         return emitJSDocTypedefTag(node);
82152                     case 324:
82153                         return emitJSDocCallbackTag(node);
82154                     case 313:
82155                         return emitJSDocSignature(node);
82156                     case 312:
82157                         return emitJSDocTypeLiteral(node);
82158                     case 319:
82159                     case 314:
82160                         return emitJSDocSimpleTag(node);
82161                     case 332:
82162                         return emitJSDocSeeTag(node);
82163                     case 302:
82164                         return emitJSDocNameReference(node);
82165                     case 311:
82166                         return emitJSDoc(node);
82167                 }
82168                 if (ts.isExpression(node)) {
82169                     hint = 1;
82170                     if (substituteNode !== ts.noEmitSubstitution) {
82171                         lastSubstitution = node = substituteNode(hint, node);
82172                     }
82173                 }
82174                 else if (ts.isToken(node)) {
82175                     return writeTokenNode(node, writePunctuation);
82176                 }
82177             }
82178             if (hint === 1) {
82179                 switch (node.kind) {
82180                     case 8:
82181                     case 9:
82182                         return emitNumericOrBigIntLiteral(node);
82183                     case 10:
82184                     case 13:
82185                     case 14:
82186                         return emitLiteral(node, false);
82187                     case 78:
82188                         return emitIdentifier(node);
82189                     case 94:
82190                     case 103:
82191                     case 105:
82192                     case 109:
82193                     case 107:
82194                     case 99:
82195                         writeTokenNode(node, writeKeyword);
82196                         return;
82197                     case 199:
82198                         return emitArrayLiteralExpression(node);
82199                     case 200:
82200                         return emitObjectLiteralExpression(node);
82201                     case 201:
82202                         return emitPropertyAccessExpression(node);
82203                     case 202:
82204                         return emitElementAccessExpression(node);
82205                     case 203:
82206                         return emitCallExpression(node);
82207                     case 204:
82208                         return emitNewExpression(node);
82209                     case 205:
82210                         return emitTaggedTemplateExpression(node);
82211                     case 206:
82212                         return emitTypeAssertionExpression(node);
82213                     case 207:
82214                         return emitParenthesizedExpression(node);
82215                     case 208:
82216                         return emitFunctionExpression(node);
82217                     case 209:
82218                         return emitArrowFunction(node);
82219                     case 210:
82220                         return emitDeleteExpression(node);
82221                     case 211:
82222                         return emitTypeOfExpression(node);
82223                     case 212:
82224                         return emitVoidExpression(node);
82225                     case 213:
82226                         return emitAwaitExpression(node);
82227                     case 214:
82228                         return emitPrefixUnaryExpression(node);
82229                     case 215:
82230                         return emitPostfixUnaryExpression(node);
82231                     case 216:
82232                         return emitBinaryExpression(node);
82233                     case 217:
82234                         return emitConditionalExpression(node);
82235                     case 218:
82236                         return emitTemplateExpression(node);
82237                     case 219:
82238                         return emitYieldExpression(node);
82239                     case 220:
82240                         return emitSpreadExpression(node);
82241                     case 221:
82242                         return emitClassExpression(node);
82243                     case 222:
82244                         return;
82245                     case 224:
82246                         return emitAsExpression(node);
82247                     case 225:
82248                         return emitNonNullExpression(node);
82249                     case 226:
82250                         return emitMetaProperty(node);
82251                     case 273:
82252                         return emitJsxElement(node);
82253                     case 274:
82254                         return emitJsxSelfClosingElement(node);
82255                     case 277:
82256                         return emitJsxFragment(node);
82257                     case 336:
82258                         return emitPartiallyEmittedExpression(node);
82259                     case 337:
82260                         return emitCommaList(node);
82261                 }
82262             }
82263         }
82264         function emitMappedTypeParameter(node) {
82265             emit(node.name);
82266             writeSpace();
82267             writeKeyword("in");
82268             writeSpace();
82269             emit(node.constraint);
82270         }
82271         function pipelineEmitWithSubstitution(hint, node) {
82272             ts.Debug.assert(lastNode === node || lastSubstitution === node);
82273             var pipelinePhase = getNextPipelinePhase(1, hint, node);
82274             pipelinePhase(hint, lastSubstitution);
82275             ts.Debug.assert(lastNode === node || lastSubstitution === node);
82276         }
82277         function getHelpersFromBundledSourceFiles(bundle) {
82278             var result;
82279             if (moduleKind === ts.ModuleKind.None || printerOptions.noEmitHelpers) {
82280                 return undefined;
82281             }
82282             var bundledHelpers = new ts.Map();
82283             for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) {
82284                 var sourceFile = _b[_a];
82285                 var shouldSkip = ts.getExternalHelpersModuleName(sourceFile) !== undefined;
82286                 var helpers = getSortedEmitHelpers(sourceFile);
82287                 if (!helpers)
82288                     continue;
82289                 for (var _c = 0, helpers_5 = helpers; _c < helpers_5.length; _c++) {
82290                     var helper = helpers_5[_c];
82291                     if (!helper.scoped && !shouldSkip && !bundledHelpers.get(helper.name)) {
82292                         bundledHelpers.set(helper.name, true);
82293                         (result || (result = [])).push(helper.name);
82294                     }
82295                 }
82296             }
82297             return result;
82298         }
82299         function emitHelpers(node) {
82300             var helpersEmitted = false;
82301             var bundle = node.kind === 298 ? node : undefined;
82302             if (bundle && moduleKind === ts.ModuleKind.None) {
82303                 return;
82304             }
82305             var numPrepends = bundle ? bundle.prepends.length : 0;
82306             var numNodes = bundle ? bundle.sourceFiles.length + numPrepends : 1;
82307             for (var i = 0; i < numNodes; i++) {
82308                 var currentNode = bundle ? i < numPrepends ? bundle.prepends[i] : bundle.sourceFiles[i - numPrepends] : node;
82309                 var sourceFile = ts.isSourceFile(currentNode) ? currentNode : ts.isUnparsedSource(currentNode) ? undefined : currentSourceFile;
82310                 var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.hasRecordedExternalHelpers(sourceFile));
82311                 var shouldBundle = (ts.isSourceFile(currentNode) || ts.isUnparsedSource(currentNode)) && !isOwnFileEmit;
82312                 var helpers = ts.isUnparsedSource(currentNode) ? currentNode.helpers : getSortedEmitHelpers(currentNode);
82313                 if (helpers) {
82314                     for (var _a = 0, helpers_6 = helpers; _a < helpers_6.length; _a++) {
82315                         var helper = helpers_6[_a];
82316                         if (!helper.scoped) {
82317                             if (shouldSkip)
82318                                 continue;
82319                             if (shouldBundle) {
82320                                 if (bundledHelpers.get(helper.name)) {
82321                                     continue;
82322                                 }
82323                                 bundledHelpers.set(helper.name, true);
82324                             }
82325                         }
82326                         else if (bundle) {
82327                             continue;
82328                         }
82329                         var pos = getTextPosWithWriteLine();
82330                         if (typeof helper.text === "string") {
82331                             writeLines(helper.text);
82332                         }
82333                         else {
82334                             writeLines(helper.text(makeFileLevelOptimisticUniqueName));
82335                         }
82336                         if (bundleFileInfo)
82337                             bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers", data: helper.name });
82338                         helpersEmitted = true;
82339                     }
82340                 }
82341             }
82342             return helpersEmitted;
82343         }
82344         function getSortedEmitHelpers(node) {
82345             var helpers = ts.getEmitHelpers(node);
82346             return helpers && ts.stableSort(helpers, ts.compareEmitHelpers);
82347         }
82348         function emitNumericOrBigIntLiteral(node) {
82349             emitLiteral(node, false);
82350         }
82351         function emitLiteral(node, jsxAttributeEscape) {
82352             var text = getLiteralTextOfNode(node, printerOptions.neverAsciiEscape, jsxAttributeEscape);
82353             if ((printerOptions.sourceMap || printerOptions.inlineSourceMap)
82354                 && (node.kind === 10 || ts.isTemplateLiteralKind(node.kind))) {
82355                 writeLiteral(text);
82356             }
82357             else {
82358                 writeStringLiteral(text);
82359             }
82360         }
82361         function emitUnparsedSourceOrPrepend(unparsed) {
82362             for (var _a = 0, _b = unparsed.texts; _a < _b.length; _a++) {
82363                 var text = _b[_a];
82364                 writeLine();
82365                 emit(text);
82366             }
82367         }
82368         function writeUnparsedNode(unparsed) {
82369             writer.rawWrite(unparsed.parent.text.substring(unparsed.pos, unparsed.end));
82370         }
82371         function emitUnparsedTextLike(unparsed) {
82372             var pos = getTextPosWithWriteLine();
82373             writeUnparsedNode(unparsed);
82374             if (bundleFileInfo) {
82375                 updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 294 ?
82376                     "text" :
82377                     "internal");
82378             }
82379         }
82380         function emitUnparsedSyntheticReference(unparsed) {
82381             var pos = getTextPosWithWriteLine();
82382             writeUnparsedNode(unparsed);
82383             if (bundleFileInfo) {
82384                 var section = ts.clone(unparsed.section);
82385                 section.pos = pos;
82386                 section.end = writer.getTextPos();
82387                 bundleFileInfo.sections.push(section);
82388             }
82389         }
82390         function emitIdentifier(node) {
82391             var writeText = node.symbol ? writeSymbol : write;
82392             writeText(getTextOfNode(node, false), node.symbol);
82393             emitList(node, node.typeArguments, 53776);
82394         }
82395         function emitPrivateIdentifier(node) {
82396             var writeText = node.symbol ? writeSymbol : write;
82397             writeText(getTextOfNode(node, false), node.symbol);
82398         }
82399         function emitQualifiedName(node) {
82400             emitEntityName(node.left);
82401             writePunctuation(".");
82402             emit(node.right);
82403         }
82404         function emitEntityName(node) {
82405             if (node.kind === 78) {
82406                 emitExpression(node);
82407             }
82408             else {
82409                 emit(node);
82410             }
82411         }
82412         function emitComputedPropertyName(node) {
82413             writePunctuation("[");
82414             emitExpression(node.expression);
82415             writePunctuation("]");
82416         }
82417         function emitTypeParameter(node) {
82418             emit(node.name);
82419             if (node.constraint) {
82420                 writeSpace();
82421                 writeKeyword("extends");
82422                 writeSpace();
82423                 emit(node.constraint);
82424             }
82425             if (node.default) {
82426                 writeSpace();
82427                 writeOperator("=");
82428                 writeSpace();
82429                 emit(node.default);
82430             }
82431         }
82432         function emitParameter(node) {
82433             emitDecorators(node, node.decorators);
82434             emitModifiers(node, node.modifiers);
82435             emit(node.dotDotDotToken);
82436             emitNodeWithWriter(node.name, writeParameter);
82437             emit(node.questionToken);
82438             if (node.parent && node.parent.kind === 308 && !node.name) {
82439                 emit(node.type);
82440             }
82441             else {
82442                 emitTypeAnnotation(node.type);
82443             }
82444             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);
82445         }
82446         function emitDecorator(decorator) {
82447             writePunctuation("@");
82448             emitExpression(decorator.expression);
82449         }
82450         function emitPropertySignature(node) {
82451             emitDecorators(node, node.decorators);
82452             emitModifiers(node, node.modifiers);
82453             emitNodeWithWriter(node.name, writeProperty);
82454             emit(node.questionToken);
82455             emitTypeAnnotation(node.type);
82456             writeTrailingSemicolon();
82457         }
82458         function emitPropertyDeclaration(node) {
82459             emitDecorators(node, node.decorators);
82460             emitModifiers(node, node.modifiers);
82461             emit(node.name);
82462             emit(node.questionToken);
82463             emit(node.exclamationToken);
82464             emitTypeAnnotation(node.type);
82465             emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name.end, node);
82466             writeTrailingSemicolon();
82467         }
82468         function emitMethodSignature(node) {
82469             pushNameGenerationScope(node);
82470             emitDecorators(node, node.decorators);
82471             emitModifiers(node, node.modifiers);
82472             emit(node.name);
82473             emit(node.questionToken);
82474             emitTypeParameters(node, node.typeParameters);
82475             emitParameters(node, node.parameters);
82476             emitTypeAnnotation(node.type);
82477             writeTrailingSemicolon();
82478             popNameGenerationScope(node);
82479         }
82480         function emitMethodDeclaration(node) {
82481             emitDecorators(node, node.decorators);
82482             emitModifiers(node, node.modifiers);
82483             emit(node.asteriskToken);
82484             emit(node.name);
82485             emit(node.questionToken);
82486             emitSignatureAndBody(node, emitSignatureHead);
82487         }
82488         function emitConstructor(node) {
82489             emitModifiers(node, node.modifiers);
82490             writeKeyword("constructor");
82491             emitSignatureAndBody(node, emitSignatureHead);
82492         }
82493         function emitAccessorDeclaration(node) {
82494             emitDecorators(node, node.decorators);
82495             emitModifiers(node, node.modifiers);
82496             writeKeyword(node.kind === 167 ? "get" : "set");
82497             writeSpace();
82498             emit(node.name);
82499             emitSignatureAndBody(node, emitSignatureHead);
82500         }
82501         function emitCallSignature(node) {
82502             pushNameGenerationScope(node);
82503             emitDecorators(node, node.decorators);
82504             emitModifiers(node, node.modifiers);
82505             emitTypeParameters(node, node.typeParameters);
82506             emitParameters(node, node.parameters);
82507             emitTypeAnnotation(node.type);
82508             writeTrailingSemicolon();
82509             popNameGenerationScope(node);
82510         }
82511         function emitConstructSignature(node) {
82512             pushNameGenerationScope(node);
82513             emitDecorators(node, node.decorators);
82514             emitModifiers(node, node.modifiers);
82515             writeKeyword("new");
82516             writeSpace();
82517             emitTypeParameters(node, node.typeParameters);
82518             emitParameters(node, node.parameters);
82519             emitTypeAnnotation(node.type);
82520             writeTrailingSemicolon();
82521             popNameGenerationScope(node);
82522         }
82523         function emitIndexSignature(node) {
82524             emitDecorators(node, node.decorators);
82525             emitModifiers(node, node.modifiers);
82526             emitParametersForIndexSignature(node, node.parameters);
82527             emitTypeAnnotation(node.type);
82528             writeTrailingSemicolon();
82529         }
82530         function emitTemplateTypeSpan(node) {
82531             emit(node.type);
82532             emit(node.literal);
82533         }
82534         function emitSemicolonClassElement() {
82535             writeTrailingSemicolon();
82536         }
82537         function emitTypePredicate(node) {
82538             if (node.assertsModifier) {
82539                 emit(node.assertsModifier);
82540                 writeSpace();
82541             }
82542             emit(node.parameterName);
82543             if (node.type) {
82544                 writeSpace();
82545                 writeKeyword("is");
82546                 writeSpace();
82547                 emit(node.type);
82548             }
82549         }
82550         function emitTypeReference(node) {
82551             emit(node.typeName);
82552             emitTypeArguments(node, node.typeArguments);
82553         }
82554         function emitFunctionType(node) {
82555             pushNameGenerationScope(node);
82556             emitTypeParameters(node, node.typeParameters);
82557             emitParametersForArrow(node, node.parameters);
82558             writeSpace();
82559             writePunctuation("=>");
82560             writeSpace();
82561             emit(node.type);
82562             popNameGenerationScope(node);
82563         }
82564         function emitJSDocFunctionType(node) {
82565             writeKeyword("function");
82566             emitParameters(node, node.parameters);
82567             writePunctuation(":");
82568             emit(node.type);
82569         }
82570         function emitJSDocNullableType(node) {
82571             writePunctuation("?");
82572             emit(node.type);
82573         }
82574         function emitJSDocNonNullableType(node) {
82575             writePunctuation("!");
82576             emit(node.type);
82577         }
82578         function emitJSDocOptionalType(node) {
82579             emit(node.type);
82580             writePunctuation("=");
82581         }
82582         function emitConstructorType(node) {
82583             pushNameGenerationScope(node);
82584             writeKeyword("new");
82585             writeSpace();
82586             emitTypeParameters(node, node.typeParameters);
82587             emitParameters(node, node.parameters);
82588             writeSpace();
82589             writePunctuation("=>");
82590             writeSpace();
82591             emit(node.type);
82592             popNameGenerationScope(node);
82593         }
82594         function emitTypeQuery(node) {
82595             writeKeyword("typeof");
82596             writeSpace();
82597             emit(node.exprName);
82598         }
82599         function emitTypeLiteral(node) {
82600             writePunctuation("{");
82601             var flags = ts.getEmitFlags(node) & 1 ? 768 : 32897;
82602             emitList(node, node.members, flags | 524288);
82603             writePunctuation("}");
82604         }
82605         function emitArrayType(node) {
82606             emit(node.elementType);
82607             writePunctuation("[");
82608             writePunctuation("]");
82609         }
82610         function emitRestOrJSDocVariadicType(node) {
82611             writePunctuation("...");
82612             emit(node.type);
82613         }
82614         function emitTupleType(node) {
82615             emitTokenWithComment(22, node.pos, writePunctuation, node);
82616             var flags = ts.getEmitFlags(node) & 1 ? 528 : 657;
82617             emitList(node, node.elements, flags | 524288);
82618             emitTokenWithComment(23, node.elements.end, writePunctuation, node);
82619         }
82620         function emitNamedTupleMember(node) {
82621             emit(node.dotDotDotToken);
82622             emit(node.name);
82623             emit(node.questionToken);
82624             emitTokenWithComment(58, node.name.end, writePunctuation, node);
82625             writeSpace();
82626             emit(node.type);
82627         }
82628         function emitOptionalType(node) {
82629             emit(node.type);
82630             writePunctuation("?");
82631         }
82632         function emitUnionType(node) {
82633             emitList(node, node.types, 516);
82634         }
82635         function emitIntersectionType(node) {
82636             emitList(node, node.types, 520);
82637         }
82638         function emitConditionalType(node) {
82639             emit(node.checkType);
82640             writeSpace();
82641             writeKeyword("extends");
82642             writeSpace();
82643             emit(node.extendsType);
82644             writeSpace();
82645             writePunctuation("?");
82646             writeSpace();
82647             emit(node.trueType);
82648             writeSpace();
82649             writePunctuation(":");
82650             writeSpace();
82651             emit(node.falseType);
82652         }
82653         function emitInferType(node) {
82654             writeKeyword("infer");
82655             writeSpace();
82656             emit(node.typeParameter);
82657         }
82658         function emitParenthesizedType(node) {
82659             writePunctuation("(");
82660             emit(node.type);
82661             writePunctuation(")");
82662         }
82663         function emitThisType() {
82664             writeKeyword("this");
82665         }
82666         function emitTypeOperator(node) {
82667             writeTokenText(node.operator, writeKeyword);
82668             writeSpace();
82669             emit(node.type);
82670         }
82671         function emitIndexedAccessType(node) {
82672             emit(node.objectType);
82673             writePunctuation("[");
82674             emit(node.indexType);
82675             writePunctuation("]");
82676         }
82677         function emitMappedType(node) {
82678             var emitFlags = ts.getEmitFlags(node);
82679             writePunctuation("{");
82680             if (emitFlags & 1) {
82681                 writeSpace();
82682             }
82683             else {
82684                 writeLine();
82685                 increaseIndent();
82686             }
82687             if (node.readonlyToken) {
82688                 emit(node.readonlyToken);
82689                 if (node.readonlyToken.kind !== 142) {
82690                     writeKeyword("readonly");
82691                 }
82692                 writeSpace();
82693             }
82694             writePunctuation("[");
82695             pipelineEmit(3, node.typeParameter);
82696             if (node.nameType) {
82697                 writeSpace();
82698                 writeKeyword("as");
82699                 writeSpace();
82700                 emit(node.nameType);
82701             }
82702             writePunctuation("]");
82703             if (node.questionToken) {
82704                 emit(node.questionToken);
82705                 if (node.questionToken.kind !== 57) {
82706                     writePunctuation("?");
82707                 }
82708             }
82709             writePunctuation(":");
82710             writeSpace();
82711             emit(node.type);
82712             writeTrailingSemicolon();
82713             if (emitFlags & 1) {
82714                 writeSpace();
82715             }
82716             else {
82717                 writeLine();
82718                 decreaseIndent();
82719             }
82720             writePunctuation("}");
82721         }
82722         function emitLiteralType(node) {
82723             emitExpression(node.literal);
82724         }
82725         function emitTemplateType(node) {
82726             emit(node.head);
82727             emitList(node, node.templateSpans, 262144);
82728         }
82729         function emitImportTypeNode(node) {
82730             if (node.isTypeOf) {
82731                 writeKeyword("typeof");
82732                 writeSpace();
82733             }
82734             writeKeyword("import");
82735             writePunctuation("(");
82736             emit(node.argument);
82737             writePunctuation(")");
82738             if (node.qualifier) {
82739                 writePunctuation(".");
82740                 emit(node.qualifier);
82741             }
82742             emitTypeArguments(node, node.typeArguments);
82743         }
82744         function emitObjectBindingPattern(node) {
82745             writePunctuation("{");
82746             emitList(node, node.elements, 525136);
82747             writePunctuation("}");
82748         }
82749         function emitArrayBindingPattern(node) {
82750             writePunctuation("[");
82751             emitList(node, node.elements, 524880);
82752             writePunctuation("]");
82753         }
82754         function emitBindingElement(node) {
82755             emit(node.dotDotDotToken);
82756             if (node.propertyName) {
82757                 emit(node.propertyName);
82758                 writePunctuation(":");
82759                 writeSpace();
82760             }
82761             emit(node.name);
82762             emitInitializer(node.initializer, node.name.end, node);
82763         }
82764         function emitArrayLiteralExpression(node) {
82765             var elements = node.elements;
82766             var preferNewLine = node.multiLine ? 65536 : 0;
82767             emitExpressionList(node, elements, 8914 | preferNewLine);
82768         }
82769         function emitObjectLiteralExpression(node) {
82770             ts.forEach(node.properties, generateMemberNames);
82771             var indentedFlag = ts.getEmitFlags(node) & 65536;
82772             if (indentedFlag) {
82773                 increaseIndent();
82774             }
82775             var preferNewLine = node.multiLine ? 65536 : 0;
82776             var allowTrailingComma = currentSourceFile.languageVersion >= 1 && !ts.isJsonSourceFile(currentSourceFile) ? 64 : 0;
82777             emitList(node, node.properties, 526226 | allowTrailingComma | preferNewLine);
82778             if (indentedFlag) {
82779                 decreaseIndent();
82780             }
82781         }
82782         function emitPropertyAccessExpression(node) {
82783             var expression = ts.cast(emitExpression(node.expression), ts.isExpression);
82784             var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24), node.expression.end, node.name.pos);
82785             var linesBeforeDot = getLinesBetweenNodes(node, node.expression, token);
82786             var linesAfterDot = getLinesBetweenNodes(node, token, node.name);
82787             writeLinesAndIndent(linesBeforeDot, false);
82788             var shouldEmitDotDot = token.kind !== 28 &&
82789                 mayNeedDotDotForPropertyAccess(expression) &&
82790                 !writer.hasTrailingComment() &&
82791                 !writer.hasTrailingWhitespace();
82792             if (shouldEmitDotDot) {
82793                 writePunctuation(".");
82794             }
82795             if (node.questionDotToken) {
82796                 emit(token);
82797             }
82798             else {
82799                 emitTokenWithComment(token.kind, node.expression.end, writePunctuation, node);
82800             }
82801             writeLinesAndIndent(linesAfterDot, false);
82802             emit(node.name);
82803             decreaseIndentIf(linesBeforeDot, linesAfterDot);
82804         }
82805         function mayNeedDotDotForPropertyAccess(expression) {
82806             expression = ts.skipPartiallyEmittedExpressions(expression);
82807             if (ts.isNumericLiteral(expression)) {
82808                 var text = getLiteralTextOfNode(expression, true, false);
82809                 return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24));
82810             }
82811             else if (ts.isAccessExpression(expression)) {
82812                 var constantValue = ts.getConstantValue(expression);
82813                 return typeof constantValue === "number" && isFinite(constantValue)
82814                     && Math.floor(constantValue) === constantValue;
82815             }
82816         }
82817         function emitElementAccessExpression(node) {
82818             emitExpression(node.expression);
82819             emit(node.questionDotToken);
82820             emitTokenWithComment(22, node.expression.end, writePunctuation, node);
82821             emitExpression(node.argumentExpression);
82822             emitTokenWithComment(23, node.argumentExpression.end, writePunctuation, node);
82823         }
82824         function emitCallExpression(node) {
82825             emitExpression(node.expression);
82826             emit(node.questionDotToken);
82827             emitTypeArguments(node, node.typeArguments);
82828             emitExpressionList(node, node.arguments, 2576);
82829         }
82830         function emitNewExpression(node) {
82831             emitTokenWithComment(102, node.pos, writeKeyword, node);
82832             writeSpace();
82833             emitExpression(node.expression);
82834             emitTypeArguments(node, node.typeArguments);
82835             emitExpressionList(node, node.arguments, 18960);
82836         }
82837         function emitTaggedTemplateExpression(node) {
82838             emitExpression(node.tag);
82839             emitTypeArguments(node, node.typeArguments);
82840             writeSpace();
82841             emitExpression(node.template);
82842         }
82843         function emitTypeAssertionExpression(node) {
82844             writePunctuation("<");
82845             emit(node.type);
82846             writePunctuation(">");
82847             emitExpression(node.expression);
82848         }
82849         function emitParenthesizedExpression(node) {
82850             var openParenPos = emitTokenWithComment(20, node.pos, writePunctuation, node);
82851             var indented = writeLineSeparatorsAndIndentBefore(node.expression, node);
82852             emitExpression(node.expression);
82853             writeLineSeparatorsAfter(node.expression, node);
82854             decreaseIndentIf(indented);
82855             emitTokenWithComment(21, node.expression ? node.expression.end : openParenPos, writePunctuation, node);
82856         }
82857         function emitFunctionExpression(node) {
82858             generateNameIfNeeded(node.name);
82859             emitFunctionDeclarationOrExpression(node);
82860         }
82861         function emitArrowFunction(node) {
82862             emitDecorators(node, node.decorators);
82863             emitModifiers(node, node.modifiers);
82864             emitSignatureAndBody(node, emitArrowFunctionHead);
82865         }
82866         function emitArrowFunctionHead(node) {
82867             emitTypeParameters(node, node.typeParameters);
82868             emitParametersForArrow(node, node.parameters);
82869             emitTypeAnnotation(node.type);
82870             writeSpace();
82871             emit(node.equalsGreaterThanToken);
82872         }
82873         function emitDeleteExpression(node) {
82874             emitTokenWithComment(88, node.pos, writeKeyword, node);
82875             writeSpace();
82876             emitExpression(node.expression);
82877         }
82878         function emitTypeOfExpression(node) {
82879             emitTokenWithComment(111, node.pos, writeKeyword, node);
82880             writeSpace();
82881             emitExpression(node.expression);
82882         }
82883         function emitVoidExpression(node) {
82884             emitTokenWithComment(113, node.pos, writeKeyword, node);
82885             writeSpace();
82886             emitExpression(node.expression);
82887         }
82888         function emitAwaitExpression(node) {
82889             emitTokenWithComment(130, node.pos, writeKeyword, node);
82890             writeSpace();
82891             emitExpression(node.expression);
82892         }
82893         function emitPrefixUnaryExpression(node) {
82894             writeTokenText(node.operator, writeOperator);
82895             if (shouldEmitWhitespaceBeforeOperand(node)) {
82896                 writeSpace();
82897             }
82898             emitExpression(node.operand);
82899         }
82900         function shouldEmitWhitespaceBeforeOperand(node) {
82901             var operand = node.operand;
82902             return operand.kind === 214
82903                 && ((node.operator === 39 && (operand.operator === 39 || operand.operator === 45))
82904                     || (node.operator === 40 && (operand.operator === 40 || operand.operator === 46)));
82905         }
82906         function emitPostfixUnaryExpression(node) {
82907             emitExpression(node.operand);
82908             writeTokenText(node.operator, writeOperator);
82909         }
82910         function emitBinaryExpression(node) {
82911             var nodeStack = [node];
82912             var stateStack = [0];
82913             var stackIndex = 0;
82914             while (stackIndex >= 0) {
82915                 node = nodeStack[stackIndex];
82916                 switch (stateStack[stackIndex]) {
82917                     case 0: {
82918                         maybePipelineEmitExpression(node.left);
82919                         break;
82920                     }
82921                     case 1: {
82922                         var isCommaOperator = node.operatorToken.kind !== 27;
82923                         var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken);
82924                         var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right);
82925                         writeLinesAndIndent(linesBeforeOperator, isCommaOperator);
82926                         emitLeadingCommentsOfPosition(node.operatorToken.pos);
82927                         writeTokenNode(node.operatorToken, node.operatorToken.kind === 100 ? writeKeyword : writeOperator);
82928                         emitTrailingCommentsOfPosition(node.operatorToken.end, true);
82929                         writeLinesAndIndent(linesAfterOperator, true);
82930                         maybePipelineEmitExpression(node.right);
82931                         break;
82932                     }
82933                     case 2: {
82934                         var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken);
82935                         var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right);
82936                         decreaseIndentIf(linesBeforeOperator, linesAfterOperator);
82937                         stackIndex--;
82938                         break;
82939                     }
82940                     default: return ts.Debug.fail("Invalid state " + stateStack[stackIndex] + " for emitBinaryExpressionWorker");
82941                 }
82942             }
82943             function maybePipelineEmitExpression(next) {
82944                 stateStack[stackIndex]++;
82945                 var savedLastNode = lastNode;
82946                 var savedLastSubstitution = lastSubstitution;
82947                 lastNode = next;
82948                 lastSubstitution = undefined;
82949                 var pipelinePhase = getPipelinePhase(0, 1, next);
82950                 if (pipelinePhase === pipelineEmitWithHint && ts.isBinaryExpression(next)) {
82951                     stackIndex++;
82952                     stateStack[stackIndex] = 0;
82953                     nodeStack[stackIndex] = next;
82954                 }
82955                 else {
82956                     pipelinePhase(1, next);
82957                 }
82958                 ts.Debug.assert(lastNode === next);
82959                 lastNode = savedLastNode;
82960                 lastSubstitution = savedLastSubstitution;
82961             }
82962         }
82963         function emitConditionalExpression(node) {
82964             var linesBeforeQuestion = getLinesBetweenNodes(node, node.condition, node.questionToken);
82965             var linesAfterQuestion = getLinesBetweenNodes(node, node.questionToken, node.whenTrue);
82966             var linesBeforeColon = getLinesBetweenNodes(node, node.whenTrue, node.colonToken);
82967             var linesAfterColon = getLinesBetweenNodes(node, node.colonToken, node.whenFalse);
82968             emitExpression(node.condition);
82969             writeLinesAndIndent(linesBeforeQuestion, true);
82970             emit(node.questionToken);
82971             writeLinesAndIndent(linesAfterQuestion, true);
82972             emitExpression(node.whenTrue);
82973             decreaseIndentIf(linesBeforeQuestion, linesAfterQuestion);
82974             writeLinesAndIndent(linesBeforeColon, true);
82975             emit(node.colonToken);
82976             writeLinesAndIndent(linesAfterColon, true);
82977             emitExpression(node.whenFalse);
82978             decreaseIndentIf(linesBeforeColon, linesAfterColon);
82979         }
82980         function emitTemplateExpression(node) {
82981             emit(node.head);
82982             emitList(node, node.templateSpans, 262144);
82983         }
82984         function emitYieldExpression(node) {
82985             emitTokenWithComment(124, node.pos, writeKeyword, node);
82986             emit(node.asteriskToken);
82987             emitExpressionWithLeadingSpace(node.expression);
82988         }
82989         function emitSpreadExpression(node) {
82990             emitTokenWithComment(25, node.pos, writePunctuation, node);
82991             emitExpression(node.expression);
82992         }
82993         function emitClassExpression(node) {
82994             generateNameIfNeeded(node.name);
82995             emitClassDeclarationOrExpression(node);
82996         }
82997         function emitExpressionWithTypeArguments(node) {
82998             emitExpression(node.expression);
82999             emitTypeArguments(node, node.typeArguments);
83000         }
83001         function emitAsExpression(node) {
83002             emitExpression(node.expression);
83003             if (node.type) {
83004                 writeSpace();
83005                 writeKeyword("as");
83006                 writeSpace();
83007                 emit(node.type);
83008             }
83009         }
83010         function emitNonNullExpression(node) {
83011             emitExpression(node.expression);
83012             writeOperator("!");
83013         }
83014         function emitMetaProperty(node) {
83015             writeToken(node.keywordToken, node.pos, writePunctuation);
83016             writePunctuation(".");
83017             emit(node.name);
83018         }
83019         function emitTemplateSpan(node) {
83020             emitExpression(node.expression);
83021             emit(node.literal);
83022         }
83023         function emitBlock(node) {
83024             emitBlockStatements(node, !node.multiLine && isEmptyBlock(node));
83025         }
83026         function emitBlockStatements(node, forceSingleLine) {
83027             emitTokenWithComment(18, node.pos, writePunctuation, node);
83028             var format = forceSingleLine || ts.getEmitFlags(node) & 1 ? 768 : 129;
83029             emitList(node, node.statements, format);
83030             emitTokenWithComment(19, node.statements.end, writePunctuation, node, !!(format & 1));
83031         }
83032         function emitVariableStatement(node) {
83033             emitModifiers(node, node.modifiers);
83034             emit(node.declarationList);
83035             writeTrailingSemicolon();
83036         }
83037         function emitEmptyStatement(isEmbeddedStatement) {
83038             if (isEmbeddedStatement) {
83039                 writePunctuation(";");
83040             }
83041             else {
83042                 writeTrailingSemicolon();
83043             }
83044         }
83045         function emitExpressionStatement(node) {
83046             emitExpression(node.expression);
83047             if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
83048                 writeTrailingSemicolon();
83049             }
83050         }
83051         function emitIfStatement(node) {
83052             var openParenPos = emitTokenWithComment(98, node.pos, writeKeyword, node);
83053             writeSpace();
83054             emitTokenWithComment(20, openParenPos, writePunctuation, node);
83055             emitExpression(node.expression);
83056             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
83057             emitEmbeddedStatement(node, node.thenStatement);
83058             if (node.elseStatement) {
83059                 writeLineOrSpace(node, node.thenStatement, node.elseStatement);
83060                 emitTokenWithComment(90, node.thenStatement.end, writeKeyword, node);
83061                 if (node.elseStatement.kind === 234) {
83062                     writeSpace();
83063                     emit(node.elseStatement);
83064                 }
83065                 else {
83066                     emitEmbeddedStatement(node, node.elseStatement);
83067                 }
83068             }
83069         }
83070         function emitWhileClause(node, startPos) {
83071             var openParenPos = emitTokenWithComment(114, startPos, writeKeyword, node);
83072             writeSpace();
83073             emitTokenWithComment(20, openParenPos, writePunctuation, node);
83074             emitExpression(node.expression);
83075             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
83076         }
83077         function emitDoStatement(node) {
83078             emitTokenWithComment(89, node.pos, writeKeyword, node);
83079             emitEmbeddedStatement(node, node.statement);
83080             if (ts.isBlock(node.statement) && !preserveSourceNewlines) {
83081                 writeSpace();
83082             }
83083             else {
83084                 writeLineOrSpace(node, node.statement, node.expression);
83085             }
83086             emitWhileClause(node, node.statement.end);
83087             writeTrailingSemicolon();
83088         }
83089         function emitWhileStatement(node) {
83090             emitWhileClause(node, node.pos);
83091             emitEmbeddedStatement(node, node.statement);
83092         }
83093         function emitForStatement(node) {
83094             var openParenPos = emitTokenWithComment(96, node.pos, writeKeyword, node);
83095             writeSpace();
83096             var pos = emitTokenWithComment(20, openParenPos, writePunctuation, node);
83097             emitForBinding(node.initializer);
83098             pos = emitTokenWithComment(26, node.initializer ? node.initializer.end : pos, writePunctuation, node);
83099             emitExpressionWithLeadingSpace(node.condition);
83100             pos = emitTokenWithComment(26, node.condition ? node.condition.end : pos, writePunctuation, node);
83101             emitExpressionWithLeadingSpace(node.incrementor);
83102             emitTokenWithComment(21, node.incrementor ? node.incrementor.end : pos, writePunctuation, node);
83103             emitEmbeddedStatement(node, node.statement);
83104         }
83105         function emitForInStatement(node) {
83106             var openParenPos = emitTokenWithComment(96, node.pos, writeKeyword, node);
83107             writeSpace();
83108             emitTokenWithComment(20, openParenPos, writePunctuation, node);
83109             emitForBinding(node.initializer);
83110             writeSpace();
83111             emitTokenWithComment(100, node.initializer.end, writeKeyword, node);
83112             writeSpace();
83113             emitExpression(node.expression);
83114             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
83115             emitEmbeddedStatement(node, node.statement);
83116         }
83117         function emitForOfStatement(node) {
83118             var openParenPos = emitTokenWithComment(96, node.pos, writeKeyword, node);
83119             writeSpace();
83120             emitWithTrailingSpace(node.awaitModifier);
83121             emitTokenWithComment(20, openParenPos, writePunctuation, node);
83122             emitForBinding(node.initializer);
83123             writeSpace();
83124             emitTokenWithComment(156, node.initializer.end, writeKeyword, node);
83125             writeSpace();
83126             emitExpression(node.expression);
83127             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
83128             emitEmbeddedStatement(node, node.statement);
83129         }
83130         function emitForBinding(node) {
83131             if (node !== undefined) {
83132                 if (node.kind === 250) {
83133                     emit(node);
83134                 }
83135                 else {
83136                     emitExpression(node);
83137                 }
83138             }
83139         }
83140         function emitContinueStatement(node) {
83141             emitTokenWithComment(85, node.pos, writeKeyword, node);
83142             emitWithLeadingSpace(node.label);
83143             writeTrailingSemicolon();
83144         }
83145         function emitBreakStatement(node) {
83146             emitTokenWithComment(80, node.pos, writeKeyword, node);
83147             emitWithLeadingSpace(node.label);
83148             writeTrailingSemicolon();
83149         }
83150         function emitTokenWithComment(token, pos, writer, contextNode, indentLeading) {
83151             var node = ts.getParseTreeNode(contextNode);
83152             var isSimilarNode = node && node.kind === contextNode.kind;
83153             var startPos = pos;
83154             if (isSimilarNode && currentSourceFile) {
83155                 pos = ts.skipTrivia(currentSourceFile.text, pos);
83156             }
83157             if (emitLeadingCommentsOfPosition && isSimilarNode && contextNode.pos !== startPos) {
83158                 var needsIndent = indentLeading && currentSourceFile && !ts.positionsAreOnSameLine(startPos, pos, currentSourceFile);
83159                 if (needsIndent) {
83160                     increaseIndent();
83161                 }
83162                 emitLeadingCommentsOfPosition(startPos);
83163                 if (needsIndent) {
83164                     decreaseIndent();
83165                 }
83166             }
83167             pos = writeTokenText(token, writer, pos);
83168             if (emitTrailingCommentsOfPosition && isSimilarNode && contextNode.end !== pos) {
83169                 emitTrailingCommentsOfPosition(pos, true);
83170             }
83171             return pos;
83172         }
83173         function emitReturnStatement(node) {
83174             emitTokenWithComment(104, node.pos, writeKeyword, node);
83175             emitExpressionWithLeadingSpace(node.expression);
83176             writeTrailingSemicolon();
83177         }
83178         function emitWithStatement(node) {
83179             var openParenPos = emitTokenWithComment(115, node.pos, writeKeyword, node);
83180             writeSpace();
83181             emitTokenWithComment(20, openParenPos, writePunctuation, node);
83182             emitExpression(node.expression);
83183             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
83184             emitEmbeddedStatement(node, node.statement);
83185         }
83186         function emitSwitchStatement(node) {
83187             var openParenPos = emitTokenWithComment(106, node.pos, writeKeyword, node);
83188             writeSpace();
83189             emitTokenWithComment(20, openParenPos, writePunctuation, node);
83190             emitExpression(node.expression);
83191             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
83192             writeSpace();
83193             emit(node.caseBlock);
83194         }
83195         function emitLabeledStatement(node) {
83196             emit(node.label);
83197             emitTokenWithComment(58, node.label.end, writePunctuation, node);
83198             writeSpace();
83199             emit(node.statement);
83200         }
83201         function emitThrowStatement(node) {
83202             emitTokenWithComment(108, node.pos, writeKeyword, node);
83203             emitExpressionWithLeadingSpace(node.expression);
83204             writeTrailingSemicolon();
83205         }
83206         function emitTryStatement(node) {
83207             emitTokenWithComment(110, node.pos, writeKeyword, node);
83208             writeSpace();
83209             emit(node.tryBlock);
83210             if (node.catchClause) {
83211                 writeLineOrSpace(node, node.tryBlock, node.catchClause);
83212                 emit(node.catchClause);
83213             }
83214             if (node.finallyBlock) {
83215                 writeLineOrSpace(node, node.catchClause || node.tryBlock, node.finallyBlock);
83216                 emitTokenWithComment(95, (node.catchClause || node.tryBlock).end, writeKeyword, node);
83217                 writeSpace();
83218                 emit(node.finallyBlock);
83219             }
83220         }
83221         function emitDebuggerStatement(node) {
83222             writeToken(86, node.pos, writeKeyword);
83223             writeTrailingSemicolon();
83224         }
83225         function emitVariableDeclaration(node) {
83226             emit(node.name);
83227             emit(node.exclamationToken);
83228             emitTypeAnnotation(node.type);
83229             emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node);
83230         }
83231         function emitVariableDeclarationList(node) {
83232             writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var");
83233             writeSpace();
83234             emitList(node, node.declarations, 528);
83235         }
83236         function emitFunctionDeclaration(node) {
83237             emitFunctionDeclarationOrExpression(node);
83238         }
83239         function emitFunctionDeclarationOrExpression(node) {
83240             emitDecorators(node, node.decorators);
83241             emitModifiers(node, node.modifiers);
83242             writeKeyword("function");
83243             emit(node.asteriskToken);
83244             writeSpace();
83245             emitIdentifierName(node.name);
83246             emitSignatureAndBody(node, emitSignatureHead);
83247         }
83248         function emitBlockCallback(_hint, body) {
83249             emitBlockFunctionBody(body);
83250         }
83251         function emitSignatureAndBody(node, emitSignatureHead) {
83252             var body = node.body;
83253             if (body) {
83254                 if (ts.isBlock(body)) {
83255                     var indentedFlag = ts.getEmitFlags(node) & 65536;
83256                     if (indentedFlag) {
83257                         increaseIndent();
83258                     }
83259                     pushNameGenerationScope(node);
83260                     ts.forEach(node.parameters, generateNames);
83261                     generateNames(node.body);
83262                     emitSignatureHead(node);
83263                     if (onEmitNode) {
83264                         onEmitNode(4, body, emitBlockCallback);
83265                     }
83266                     else {
83267                         emitBlockFunctionBody(body);
83268                     }
83269                     popNameGenerationScope(node);
83270                     if (indentedFlag) {
83271                         decreaseIndent();
83272                     }
83273                 }
83274                 else {
83275                     emitSignatureHead(node);
83276                     writeSpace();
83277                     emitExpression(body);
83278                 }
83279             }
83280             else {
83281                 emitSignatureHead(node);
83282                 writeTrailingSemicolon();
83283             }
83284         }
83285         function emitSignatureHead(node) {
83286             emitTypeParameters(node, node.typeParameters);
83287             emitParameters(node, node.parameters);
83288             emitTypeAnnotation(node.type);
83289         }
83290         function shouldEmitBlockFunctionBodyOnSingleLine(body) {
83291             if (ts.getEmitFlags(body) & 1) {
83292                 return true;
83293             }
83294             if (body.multiLine) {
83295                 return false;
83296             }
83297             if (!ts.nodeIsSynthesized(body) && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
83298                 return false;
83299             }
83300             if (getLeadingLineTerminatorCount(body, body.statements, 2)
83301                 || getClosingLineTerminatorCount(body, body.statements, 2)) {
83302                 return false;
83303             }
83304             var previousStatement;
83305             for (var _a = 0, _b = body.statements; _a < _b.length; _a++) {
83306                 var statement = _b[_a];
83307                 if (getSeparatingLineTerminatorCount(previousStatement, statement, 2) > 0) {
83308                     return false;
83309                 }
83310                 previousStatement = statement;
83311             }
83312             return true;
83313         }
83314         function emitBlockFunctionBody(body) {
83315             writeSpace();
83316             writePunctuation("{");
83317             increaseIndent();
83318             var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body)
83319                 ? emitBlockFunctionBodyOnSingleLine
83320                 : emitBlockFunctionBodyWorker;
83321             if (emitBodyWithDetachedComments) {
83322                 emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
83323             }
83324             else {
83325                 emitBlockFunctionBody(body);
83326             }
83327             decreaseIndent();
83328             writeToken(19, body.statements.end, writePunctuation, body);
83329         }
83330         function emitBlockFunctionBodyOnSingleLine(body) {
83331             emitBlockFunctionBodyWorker(body, true);
83332         }
83333         function emitBlockFunctionBodyWorker(body, emitBlockFunctionBodyOnSingleLine) {
83334             var statementOffset = emitPrologueDirectives(body.statements);
83335             var pos = writer.getTextPos();
83336             emitHelpers(body);
83337             if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) {
83338                 decreaseIndent();
83339                 emitList(body, body.statements, 768);
83340                 increaseIndent();
83341             }
83342             else {
83343                 emitList(body, body.statements, 1, statementOffset);
83344             }
83345         }
83346         function emitClassDeclaration(node) {
83347             emitClassDeclarationOrExpression(node);
83348         }
83349         function emitClassDeclarationOrExpression(node) {
83350             ts.forEach(node.members, generateMemberNames);
83351             emitDecorators(node, node.decorators);
83352             emitModifiers(node, node.modifiers);
83353             writeKeyword("class");
83354             if (node.name) {
83355                 writeSpace();
83356                 emitIdentifierName(node.name);
83357             }
83358             var indentedFlag = ts.getEmitFlags(node) & 65536;
83359             if (indentedFlag) {
83360                 increaseIndent();
83361             }
83362             emitTypeParameters(node, node.typeParameters);
83363             emitList(node, node.heritageClauses, 0);
83364             writeSpace();
83365             writePunctuation("{");
83366             emitList(node, node.members, 129);
83367             writePunctuation("}");
83368             if (indentedFlag) {
83369                 decreaseIndent();
83370             }
83371         }
83372         function emitInterfaceDeclaration(node) {
83373             emitDecorators(node, node.decorators);
83374             emitModifiers(node, node.modifiers);
83375             writeKeyword("interface");
83376             writeSpace();
83377             emit(node.name);
83378             emitTypeParameters(node, node.typeParameters);
83379             emitList(node, node.heritageClauses, 512);
83380             writeSpace();
83381             writePunctuation("{");
83382             emitList(node, node.members, 129);
83383             writePunctuation("}");
83384         }
83385         function emitTypeAliasDeclaration(node) {
83386             emitDecorators(node, node.decorators);
83387             emitModifiers(node, node.modifiers);
83388             writeKeyword("type");
83389             writeSpace();
83390             emit(node.name);
83391             emitTypeParameters(node, node.typeParameters);
83392             writeSpace();
83393             writePunctuation("=");
83394             writeSpace();
83395             emit(node.type);
83396             writeTrailingSemicolon();
83397         }
83398         function emitEnumDeclaration(node) {
83399             emitModifiers(node, node.modifiers);
83400             writeKeyword("enum");
83401             writeSpace();
83402             emit(node.name);
83403             writeSpace();
83404             writePunctuation("{");
83405             emitList(node, node.members, 145);
83406             writePunctuation("}");
83407         }
83408         function emitModuleDeclaration(node) {
83409             emitModifiers(node, node.modifiers);
83410             if (~node.flags & 1024) {
83411                 writeKeyword(node.flags & 16 ? "namespace" : "module");
83412                 writeSpace();
83413             }
83414             emit(node.name);
83415             var body = node.body;
83416             if (!body)
83417                 return writeTrailingSemicolon();
83418             while (body.kind === 256) {
83419                 writePunctuation(".");
83420                 emit(body.name);
83421                 body = body.body;
83422             }
83423             writeSpace();
83424             emit(body);
83425         }
83426         function emitModuleBlock(node) {
83427             pushNameGenerationScope(node);
83428             ts.forEach(node.statements, generateNames);
83429             emitBlockStatements(node, isEmptyBlock(node));
83430             popNameGenerationScope(node);
83431         }
83432         function emitCaseBlock(node) {
83433             emitTokenWithComment(18, node.pos, writePunctuation, node);
83434             emitList(node, node.clauses, 129);
83435             emitTokenWithComment(19, node.clauses.end, writePunctuation, node, true);
83436         }
83437         function emitImportEqualsDeclaration(node) {
83438             emitModifiers(node, node.modifiers);
83439             emitTokenWithComment(99, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node);
83440             writeSpace();
83441             emit(node.name);
83442             writeSpace();
83443             emitTokenWithComment(62, node.name.end, writePunctuation, node);
83444             writeSpace();
83445             emitModuleReference(node.moduleReference);
83446             writeTrailingSemicolon();
83447         }
83448         function emitModuleReference(node) {
83449             if (node.kind === 78) {
83450                 emitExpression(node);
83451             }
83452             else {
83453                 emit(node);
83454             }
83455         }
83456         function emitImportDeclaration(node) {
83457             emitModifiers(node, node.modifiers);
83458             emitTokenWithComment(99, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node);
83459             writeSpace();
83460             if (node.importClause) {
83461                 emit(node.importClause);
83462                 writeSpace();
83463                 emitTokenWithComment(153, node.importClause.end, writeKeyword, node);
83464                 writeSpace();
83465             }
83466             emitExpression(node.moduleSpecifier);
83467             writeTrailingSemicolon();
83468         }
83469         function emitImportClause(node) {
83470             if (node.isTypeOnly) {
83471                 emitTokenWithComment(149, node.pos, writeKeyword, node);
83472                 writeSpace();
83473             }
83474             emit(node.name);
83475             if (node.name && node.namedBindings) {
83476                 emitTokenWithComment(27, node.name.end, writePunctuation, node);
83477                 writeSpace();
83478             }
83479             emit(node.namedBindings);
83480         }
83481         function emitNamespaceImport(node) {
83482             var asPos = emitTokenWithComment(41, node.pos, writePunctuation, node);
83483             writeSpace();
83484             emitTokenWithComment(126, asPos, writeKeyword, node);
83485             writeSpace();
83486             emit(node.name);
83487         }
83488         function emitNamedImports(node) {
83489             emitNamedImportsOrExports(node);
83490         }
83491         function emitImportSpecifier(node) {
83492             emitImportOrExportSpecifier(node);
83493         }
83494         function emitExportAssignment(node) {
83495             var nextPos = emitTokenWithComment(92, node.pos, writeKeyword, node);
83496             writeSpace();
83497             if (node.isExportEquals) {
83498                 emitTokenWithComment(62, nextPos, writeOperator, node);
83499             }
83500             else {
83501                 emitTokenWithComment(87, nextPos, writeKeyword, node);
83502             }
83503             writeSpace();
83504             emitExpression(node.expression);
83505             writeTrailingSemicolon();
83506         }
83507         function emitExportDeclaration(node) {
83508             var nextPos = emitTokenWithComment(92, node.pos, writeKeyword, node);
83509             writeSpace();
83510             if (node.isTypeOnly) {
83511                 nextPos = emitTokenWithComment(149, nextPos, writeKeyword, node);
83512                 writeSpace();
83513             }
83514             if (node.exportClause) {
83515                 emit(node.exportClause);
83516             }
83517             else {
83518                 nextPos = emitTokenWithComment(41, nextPos, writePunctuation, node);
83519             }
83520             if (node.moduleSpecifier) {
83521                 writeSpace();
83522                 var fromPos = node.exportClause ? node.exportClause.end : nextPos;
83523                 emitTokenWithComment(153, fromPos, writeKeyword, node);
83524                 writeSpace();
83525                 emitExpression(node.moduleSpecifier);
83526             }
83527             writeTrailingSemicolon();
83528         }
83529         function emitNamespaceExportDeclaration(node) {
83530             var nextPos = emitTokenWithComment(92, node.pos, writeKeyword, node);
83531             writeSpace();
83532             nextPos = emitTokenWithComment(126, nextPos, writeKeyword, node);
83533             writeSpace();
83534             nextPos = emitTokenWithComment(140, nextPos, writeKeyword, node);
83535             writeSpace();
83536             emit(node.name);
83537             writeTrailingSemicolon();
83538         }
83539         function emitNamespaceExport(node) {
83540             var asPos = emitTokenWithComment(41, node.pos, writePunctuation, node);
83541             writeSpace();
83542             emitTokenWithComment(126, asPos, writeKeyword, node);
83543             writeSpace();
83544             emit(node.name);
83545         }
83546         function emitNamedExports(node) {
83547             emitNamedImportsOrExports(node);
83548         }
83549         function emitExportSpecifier(node) {
83550             emitImportOrExportSpecifier(node);
83551         }
83552         function emitNamedImportsOrExports(node) {
83553             writePunctuation("{");
83554             emitList(node, node.elements, 525136);
83555             writePunctuation("}");
83556         }
83557         function emitImportOrExportSpecifier(node) {
83558             if (node.propertyName) {
83559                 emit(node.propertyName);
83560                 writeSpace();
83561                 emitTokenWithComment(126, node.propertyName.end, writeKeyword, node);
83562                 writeSpace();
83563             }
83564             emit(node.name);
83565         }
83566         function emitExternalModuleReference(node) {
83567             writeKeyword("require");
83568             writePunctuation("(");
83569             emitExpression(node.expression);
83570             writePunctuation(")");
83571         }
83572         function emitJsxElement(node) {
83573             emit(node.openingElement);
83574             emitList(node, node.children, 262144);
83575             emit(node.closingElement);
83576         }
83577         function emitJsxSelfClosingElement(node) {
83578             writePunctuation("<");
83579             emitJsxTagName(node.tagName);
83580             emitTypeArguments(node, node.typeArguments);
83581             writeSpace();
83582             emit(node.attributes);
83583             writePunctuation("/>");
83584         }
83585         function emitJsxFragment(node) {
83586             emit(node.openingFragment);
83587             emitList(node, node.children, 262144);
83588             emit(node.closingFragment);
83589         }
83590         function emitJsxOpeningElementOrFragment(node) {
83591             writePunctuation("<");
83592             if (ts.isJsxOpeningElement(node)) {
83593                 var indented = writeLineSeparatorsAndIndentBefore(node.tagName, node);
83594                 emitJsxTagName(node.tagName);
83595                 emitTypeArguments(node, node.typeArguments);
83596                 if (node.attributes.properties && node.attributes.properties.length > 0) {
83597                     writeSpace();
83598                 }
83599                 emit(node.attributes);
83600                 writeLineSeparatorsAfter(node.attributes, node);
83601                 decreaseIndentIf(indented);
83602             }
83603             writePunctuation(">");
83604         }
83605         function emitJsxText(node) {
83606             writer.writeLiteral(node.text);
83607         }
83608         function emitJsxClosingElementOrFragment(node) {
83609             writePunctuation("</");
83610             if (ts.isJsxClosingElement(node)) {
83611                 emitJsxTagName(node.tagName);
83612             }
83613             writePunctuation(">");
83614         }
83615         function emitJsxAttributes(node) {
83616             emitList(node, node.properties, 262656);
83617         }
83618         function emitJsxAttribute(node) {
83619             emit(node.name);
83620             emitNodeWithPrefix("=", writePunctuation, node.initializer, emitJsxAttributeValue);
83621         }
83622         function emitJsxSpreadAttribute(node) {
83623             writePunctuation("{...");
83624             emitExpression(node.expression);
83625             writePunctuation("}");
83626         }
83627         function emitJsxExpression(node) {
83628             if (node.expression) {
83629                 writePunctuation("{");
83630                 emit(node.dotDotDotToken);
83631                 emitExpression(node.expression);
83632                 writePunctuation("}");
83633             }
83634         }
83635         function emitJsxTagName(node) {
83636             if (node.kind === 78) {
83637                 emitExpression(node);
83638             }
83639             else {
83640                 emit(node);
83641             }
83642         }
83643         function emitCaseClause(node) {
83644             emitTokenWithComment(81, node.pos, writeKeyword, node);
83645             writeSpace();
83646             emitExpression(node.expression);
83647             emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end);
83648         }
83649         function emitDefaultClause(node) {
83650             var pos = emitTokenWithComment(87, node.pos, writeKeyword, node);
83651             emitCaseOrDefaultClauseRest(node, node.statements, pos);
83652         }
83653         function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) {
83654             var emitAsSingleStatement = statements.length === 1 &&
83655                 (ts.nodeIsSynthesized(parentNode) ||
83656                     ts.nodeIsSynthesized(statements[0]) ||
83657                     ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile));
83658             var format = 163969;
83659             if (emitAsSingleStatement) {
83660                 writeToken(58, colonPos, writePunctuation, parentNode);
83661                 writeSpace();
83662                 format &= ~(1 | 128);
83663             }
83664             else {
83665                 emitTokenWithComment(58, colonPos, writePunctuation, parentNode);
83666             }
83667             emitList(parentNode, statements, format);
83668         }
83669         function emitHeritageClause(node) {
83670             writeSpace();
83671             writeTokenText(node.token, writeKeyword);
83672             writeSpace();
83673             emitList(node, node.types, 528);
83674         }
83675         function emitCatchClause(node) {
83676             var openParenPos = emitTokenWithComment(82, node.pos, writeKeyword, node);
83677             writeSpace();
83678             if (node.variableDeclaration) {
83679                 emitTokenWithComment(20, openParenPos, writePunctuation, node);
83680                 emit(node.variableDeclaration);
83681                 emitTokenWithComment(21, node.variableDeclaration.end, writePunctuation, node);
83682                 writeSpace();
83683             }
83684             emit(node.block);
83685         }
83686         function emitPropertyAssignment(node) {
83687             emit(node.name);
83688             writePunctuation(":");
83689             writeSpace();
83690             var initializer = node.initializer;
83691             if (emitTrailingCommentsOfPosition && (ts.getEmitFlags(initializer) & 512) === 0) {
83692                 var commentRange = ts.getCommentRange(initializer);
83693                 emitTrailingCommentsOfPosition(commentRange.pos);
83694             }
83695             emitExpression(initializer);
83696         }
83697         function emitShorthandPropertyAssignment(node) {
83698             emit(node.name);
83699             if (node.objectAssignmentInitializer) {
83700                 writeSpace();
83701                 writePunctuation("=");
83702                 writeSpace();
83703                 emitExpression(node.objectAssignmentInitializer);
83704             }
83705         }
83706         function emitSpreadAssignment(node) {
83707             if (node.expression) {
83708                 emitTokenWithComment(25, node.pos, writePunctuation, node);
83709                 emitExpression(node.expression);
83710             }
83711         }
83712         function emitEnumMember(node) {
83713             emit(node.name);
83714             emitInitializer(node.initializer, node.name.end, node);
83715         }
83716         function emitJSDoc(node) {
83717             write("/**");
83718             if (node.comment) {
83719                 var lines = node.comment.split(/\r\n?|\n/g);
83720                 for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) {
83721                     var line = lines_2[_a];
83722                     writeLine();
83723                     writeSpace();
83724                     writePunctuation("*");
83725                     writeSpace();
83726                     write(line);
83727                 }
83728             }
83729             if (node.tags) {
83730                 if (node.tags.length === 1 && node.tags[0].kind === 329 && !node.comment) {
83731                     writeSpace();
83732                     emit(node.tags[0]);
83733                 }
83734                 else {
83735                     emitList(node, node.tags, 33);
83736                 }
83737             }
83738             writeSpace();
83739             write("*/");
83740         }
83741         function emitJSDocSimpleTypedTag(tag) {
83742             emitJSDocTagName(tag.tagName);
83743             emitJSDocTypeExpression(tag.typeExpression);
83744             emitJSDocComment(tag.comment);
83745         }
83746         function emitJSDocSeeTag(tag) {
83747             emitJSDocTagName(tag.tagName);
83748             emit(tag.name);
83749             emitJSDocComment(tag.comment);
83750         }
83751         function emitJSDocNameReference(node) {
83752             writeSpace();
83753             writePunctuation("{");
83754             emit(node.name);
83755             writePunctuation("}");
83756         }
83757         function emitJSDocHeritageTag(tag) {
83758             emitJSDocTagName(tag.tagName);
83759             writeSpace();
83760             writePunctuation("{");
83761             emit(tag.class);
83762             writePunctuation("}");
83763             emitJSDocComment(tag.comment);
83764         }
83765         function emitJSDocTemplateTag(tag) {
83766             emitJSDocTagName(tag.tagName);
83767             emitJSDocTypeExpression(tag.constraint);
83768             writeSpace();
83769             emitList(tag, tag.typeParameters, 528);
83770             emitJSDocComment(tag.comment);
83771         }
83772         function emitJSDocTypedefTag(tag) {
83773             emitJSDocTagName(tag.tagName);
83774             if (tag.typeExpression) {
83775                 if (tag.typeExpression.kind === 301) {
83776                     emitJSDocTypeExpression(tag.typeExpression);
83777                 }
83778                 else {
83779                     writeSpace();
83780                     writePunctuation("{");
83781                     write("Object");
83782                     if (tag.typeExpression.isArrayType) {
83783                         writePunctuation("[");
83784                         writePunctuation("]");
83785                     }
83786                     writePunctuation("}");
83787                 }
83788             }
83789             if (tag.fullName) {
83790                 writeSpace();
83791                 emit(tag.fullName);
83792             }
83793             emitJSDocComment(tag.comment);
83794             if (tag.typeExpression && tag.typeExpression.kind === 312) {
83795                 emitJSDocTypeLiteral(tag.typeExpression);
83796             }
83797         }
83798         function emitJSDocCallbackTag(tag) {
83799             emitJSDocTagName(tag.tagName);
83800             if (tag.name) {
83801                 writeSpace();
83802                 emit(tag.name);
83803             }
83804             emitJSDocComment(tag.comment);
83805             emitJSDocSignature(tag.typeExpression);
83806         }
83807         function emitJSDocSimpleTag(tag) {
83808             emitJSDocTagName(tag.tagName);
83809             emitJSDocComment(tag.comment);
83810         }
83811         function emitJSDocTypeLiteral(lit) {
83812             emitList(lit, ts.factory.createNodeArray(lit.jsDocPropertyTags), 33);
83813         }
83814         function emitJSDocSignature(sig) {
83815             if (sig.typeParameters) {
83816                 emitList(sig, ts.factory.createNodeArray(sig.typeParameters), 33);
83817             }
83818             if (sig.parameters) {
83819                 emitList(sig, ts.factory.createNodeArray(sig.parameters), 33);
83820             }
83821             if (sig.type) {
83822                 writeLine();
83823                 writeSpace();
83824                 writePunctuation("*");
83825                 writeSpace();
83826                 emit(sig.type);
83827             }
83828         }
83829         function emitJSDocPropertyLikeTag(param) {
83830             emitJSDocTagName(param.tagName);
83831             emitJSDocTypeExpression(param.typeExpression);
83832             writeSpace();
83833             if (param.isBracketed) {
83834                 writePunctuation("[");
83835             }
83836             emit(param.name);
83837             if (param.isBracketed) {
83838                 writePunctuation("]");
83839             }
83840             emitJSDocComment(param.comment);
83841         }
83842         function emitJSDocTagName(tagName) {
83843             writePunctuation("@");
83844             emit(tagName);
83845         }
83846         function emitJSDocComment(comment) {
83847             if (comment) {
83848                 writeSpace();
83849                 write(comment);
83850             }
83851         }
83852         function emitJSDocTypeExpression(typeExpression) {
83853             if (typeExpression) {
83854                 writeSpace();
83855                 writePunctuation("{");
83856                 emit(typeExpression.type);
83857                 writePunctuation("}");
83858             }
83859         }
83860         function emitSourceFile(node) {
83861             writeLine();
83862             var statements = node.statements;
83863             if (emitBodyWithDetachedComments) {
83864                 var shouldEmitDetachedComment = statements.length === 0 ||
83865                     !ts.isPrologueDirective(statements[0]) ||
83866                     ts.nodeIsSynthesized(statements[0]);
83867                 if (shouldEmitDetachedComment) {
83868                     emitBodyWithDetachedComments(node, statements, emitSourceFileWorker);
83869                     return;
83870                 }
83871             }
83872             emitSourceFileWorker(node);
83873         }
83874         function emitSyntheticTripleSlashReferencesIfNeeded(node) {
83875             emitTripleSlashDirectives(!!node.hasNoDefaultLib, node.syntheticFileReferences || [], node.syntheticTypeReferences || [], node.syntheticLibReferences || []);
83876             for (var _a = 0, _b = node.prepends; _a < _b.length; _a++) {
83877                 var prepend = _b[_a];
83878                 if (ts.isUnparsedSource(prepend) && prepend.syntheticReferences) {
83879                     for (var _c = 0, _d = prepend.syntheticReferences; _c < _d.length; _c++) {
83880                         var ref = _d[_c];
83881                         emit(ref);
83882                         writeLine();
83883                     }
83884                 }
83885             }
83886         }
83887         function emitTripleSlashDirectivesIfNeeded(node) {
83888             if (node.isDeclarationFile)
83889                 emitTripleSlashDirectives(node.hasNoDefaultLib, node.referencedFiles, node.typeReferenceDirectives, node.libReferenceDirectives);
83890         }
83891         function emitTripleSlashDirectives(hasNoDefaultLib, files, types, libs) {
83892             if (hasNoDefaultLib) {
83893                 var pos = writer.getTextPos();
83894                 writeComment("/// <reference no-default-lib=\"true\"/>");
83895                 if (bundleFileInfo)
83896                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" });
83897                 writeLine();
83898             }
83899             if (currentSourceFile && currentSourceFile.moduleName) {
83900                 writeComment("/// <amd-module name=\"" + currentSourceFile.moduleName + "\" />");
83901                 writeLine();
83902             }
83903             if (currentSourceFile && currentSourceFile.amdDependencies) {
83904                 for (var _a = 0, _b = currentSourceFile.amdDependencies; _a < _b.length; _a++) {
83905                     var dep = _b[_a];
83906                     if (dep.name) {
83907                         writeComment("/// <amd-dependency name=\"" + dep.name + "\" path=\"" + dep.path + "\" />");
83908                     }
83909                     else {
83910                         writeComment("/// <amd-dependency path=\"" + dep.path + "\" />");
83911                     }
83912                     writeLine();
83913                 }
83914             }
83915             for (var _c = 0, files_1 = files; _c < files_1.length; _c++) {
83916                 var directive = files_1[_c];
83917                 var pos = writer.getTextPos();
83918                 writeComment("/// <reference path=\"" + directive.fileName + "\" />");
83919                 if (bundleFileInfo)
83920                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference", data: directive.fileName });
83921                 writeLine();
83922             }
83923             for (var _d = 0, types_23 = types; _d < types_23.length; _d++) {
83924                 var directive = types_23[_d];
83925                 var pos = writer.getTextPos();
83926                 writeComment("/// <reference types=\"" + directive.fileName + "\" />");
83927                 if (bundleFileInfo)
83928                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "type", data: directive.fileName });
83929                 writeLine();
83930             }
83931             for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) {
83932                 var directive = libs_1[_e];
83933                 var pos = writer.getTextPos();
83934                 writeComment("/// <reference lib=\"" + directive.fileName + "\" />");
83935                 if (bundleFileInfo)
83936                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib", data: directive.fileName });
83937                 writeLine();
83938             }
83939         }
83940         function emitSourceFileWorker(node) {
83941             var statements = node.statements;
83942             pushNameGenerationScope(node);
83943             ts.forEach(node.statements, generateNames);
83944             emitHelpers(node);
83945             var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); });
83946             emitTripleSlashDirectivesIfNeeded(node);
83947             emitList(node, statements, 1, index === -1 ? statements.length : index);
83948             popNameGenerationScope(node);
83949         }
83950         function emitPartiallyEmittedExpression(node) {
83951             emitExpression(node.expression);
83952         }
83953         function emitCommaList(node) {
83954             emitExpressionList(node, node.elements, 528);
83955         }
83956         function emitPrologueDirectives(statements, sourceFile, seenPrologueDirectives, recordBundleFileSection) {
83957             var needsToSetSourceFile = !!sourceFile;
83958             for (var i = 0; i < statements.length; i++) {
83959                 var statement = statements[i];
83960                 if (ts.isPrologueDirective(statement)) {
83961                     var shouldEmitPrologueDirective = seenPrologueDirectives ? !seenPrologueDirectives.has(statement.expression.text) : true;
83962                     if (shouldEmitPrologueDirective) {
83963                         if (needsToSetSourceFile) {
83964                             needsToSetSourceFile = false;
83965                             setSourceFile(sourceFile);
83966                         }
83967                         writeLine();
83968                         var pos = writer.getTextPos();
83969                         emit(statement);
83970                         if (recordBundleFileSection && bundleFileInfo)
83971                             bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue", data: statement.expression.text });
83972                         if (seenPrologueDirectives) {
83973                             seenPrologueDirectives.add(statement.expression.text);
83974                         }
83975                     }
83976                 }
83977                 else {
83978                     return i;
83979                 }
83980             }
83981             return statements.length;
83982         }
83983         function emitUnparsedPrologues(prologues, seenPrologueDirectives) {
83984             for (var _a = 0, prologues_1 = prologues; _a < prologues_1.length; _a++) {
83985                 var prologue = prologues_1[_a];
83986                 if (!seenPrologueDirectives.has(prologue.data)) {
83987                     writeLine();
83988                     var pos = writer.getTextPos();
83989                     emit(prologue);
83990                     if (bundleFileInfo)
83991                         bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue", data: prologue.data });
83992                     if (seenPrologueDirectives) {
83993                         seenPrologueDirectives.add(prologue.data);
83994                     }
83995                 }
83996             }
83997         }
83998         function emitPrologueDirectivesIfNeeded(sourceFileOrBundle) {
83999             if (ts.isSourceFile(sourceFileOrBundle)) {
84000                 emitPrologueDirectives(sourceFileOrBundle.statements, sourceFileOrBundle);
84001             }
84002             else {
84003                 var seenPrologueDirectives = new ts.Set();
84004                 for (var _a = 0, _b = sourceFileOrBundle.prepends; _a < _b.length; _a++) {
84005                     var prepend = _b[_a];
84006                     emitUnparsedPrologues(prepend.prologues, seenPrologueDirectives);
84007                 }
84008                 for (var _c = 0, _d = sourceFileOrBundle.sourceFiles; _c < _d.length; _c++) {
84009                     var sourceFile = _d[_c];
84010                     emitPrologueDirectives(sourceFile.statements, sourceFile, seenPrologueDirectives, true);
84011                 }
84012                 setSourceFile(undefined);
84013             }
84014         }
84015         function getPrologueDirectivesFromBundledSourceFiles(bundle) {
84016             var seenPrologueDirectives = new ts.Set();
84017             var prologues;
84018             for (var index = 0; index < bundle.sourceFiles.length; index++) {
84019                 var sourceFile = bundle.sourceFiles[index];
84020                 var directives = void 0;
84021                 var end = 0;
84022                 for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) {
84023                     var statement = _b[_a];
84024                     if (!ts.isPrologueDirective(statement))
84025                         break;
84026                     if (seenPrologueDirectives.has(statement.expression.text))
84027                         continue;
84028                     seenPrologueDirectives.add(statement.expression.text);
84029                     (directives || (directives = [])).push({
84030                         pos: statement.pos,
84031                         end: statement.end,
84032                         expression: {
84033                             pos: statement.expression.pos,
84034                             end: statement.expression.end,
84035                             text: statement.expression.text
84036                         }
84037                     });
84038                     end = end < statement.end ? statement.end : end;
84039                 }
84040                 if (directives)
84041                     (prologues || (prologues = [])).push({ file: index, text: sourceFile.text.substring(0, end), directives: directives });
84042             }
84043             return prologues;
84044         }
84045         function emitShebangIfNeeded(sourceFileOrBundle) {
84046             if (ts.isSourceFile(sourceFileOrBundle) || ts.isUnparsedSource(sourceFileOrBundle)) {
84047                 var shebang = ts.getShebang(sourceFileOrBundle.text);
84048                 if (shebang) {
84049                     writeComment(shebang);
84050                     writeLine();
84051                     return true;
84052                 }
84053             }
84054             else {
84055                 for (var _a = 0, _b = sourceFileOrBundle.prepends; _a < _b.length; _a++) {
84056                     var prepend = _b[_a];
84057                     ts.Debug.assertNode(prepend, ts.isUnparsedSource);
84058                     if (emitShebangIfNeeded(prepend)) {
84059                         return true;
84060                     }
84061                 }
84062                 for (var _c = 0, _d = sourceFileOrBundle.sourceFiles; _c < _d.length; _c++) {
84063                     var sourceFile = _d[_c];
84064                     if (emitShebangIfNeeded(sourceFile)) {
84065                         return true;
84066                     }
84067                 }
84068             }
84069         }
84070         function emitNodeWithWriter(node, writer) {
84071             if (!node)
84072                 return;
84073             var savedWrite = write;
84074             write = writer;
84075             emit(node);
84076             write = savedWrite;
84077         }
84078         function emitModifiers(node, modifiers) {
84079             if (modifiers && modifiers.length) {
84080                 emitList(node, modifiers, 262656);
84081                 writeSpace();
84082             }
84083         }
84084         function emitTypeAnnotation(node) {
84085             if (node) {
84086                 writePunctuation(":");
84087                 writeSpace();
84088                 emit(node);
84089             }
84090         }
84091         function emitInitializer(node, equalCommentStartPos, container) {
84092             if (node) {
84093                 writeSpace();
84094                 emitTokenWithComment(62, equalCommentStartPos, writeOperator, container);
84095                 writeSpace();
84096                 emitExpression(node);
84097             }
84098         }
84099         function emitNodeWithPrefix(prefix, prefixWriter, node, emit) {
84100             if (node) {
84101                 prefixWriter(prefix);
84102                 emit(node);
84103             }
84104         }
84105         function emitWithLeadingSpace(node) {
84106             if (node) {
84107                 writeSpace();
84108                 emit(node);
84109             }
84110         }
84111         function emitExpressionWithLeadingSpace(node) {
84112             if (node) {
84113                 writeSpace();
84114                 emitExpression(node);
84115             }
84116         }
84117         function emitWithTrailingSpace(node) {
84118             if (node) {
84119                 emit(node);
84120                 writeSpace();
84121             }
84122         }
84123         function emitEmbeddedStatement(parent, node) {
84124             if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1) {
84125                 writeSpace();
84126                 emit(node);
84127             }
84128             else {
84129                 writeLine();
84130                 increaseIndent();
84131                 if (ts.isEmptyStatement(node)) {
84132                     pipelineEmit(5, node);
84133                 }
84134                 else {
84135                     emit(node);
84136                 }
84137                 decreaseIndent();
84138             }
84139         }
84140         function emitDecorators(parentNode, decorators) {
84141             emitList(parentNode, decorators, 2146305);
84142         }
84143         function emitTypeArguments(parentNode, typeArguments) {
84144             emitList(parentNode, typeArguments, 53776);
84145         }
84146         function emitTypeParameters(parentNode, typeParameters) {
84147             if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) {
84148                 return emitTypeArguments(parentNode, parentNode.typeArguments);
84149             }
84150             emitList(parentNode, typeParameters, 53776);
84151         }
84152         function emitParameters(parentNode, parameters) {
84153             emitList(parentNode, parameters, 2576);
84154         }
84155         function canEmitSimpleArrowHead(parentNode, parameters) {
84156             var parameter = ts.singleOrUndefined(parameters);
84157             return parameter
84158                 && parameter.pos === parentNode.pos
84159                 && ts.isArrowFunction(parentNode)
84160                 && !parentNode.type
84161                 && !ts.some(parentNode.decorators)
84162                 && !ts.some(parentNode.modifiers)
84163                 && !ts.some(parentNode.typeParameters)
84164                 && !ts.some(parameter.decorators)
84165                 && !ts.some(parameter.modifiers)
84166                 && !parameter.dotDotDotToken
84167                 && !parameter.questionToken
84168                 && !parameter.type
84169                 && !parameter.initializer
84170                 && ts.isIdentifier(parameter.name);
84171         }
84172         function emitParametersForArrow(parentNode, parameters) {
84173             if (canEmitSimpleArrowHead(parentNode, parameters)) {
84174                 emitList(parentNode, parameters, 2576 & ~2048);
84175             }
84176             else {
84177                 emitParameters(parentNode, parameters);
84178             }
84179         }
84180         function emitParametersForIndexSignature(parentNode, parameters) {
84181             emitList(parentNode, parameters, 8848);
84182         }
84183         function emitList(parentNode, children, format, start, count) {
84184             emitNodeList(emit, parentNode, children, format, start, count);
84185         }
84186         function emitExpressionList(parentNode, children, format, start, count) {
84187             emitNodeList(emitExpression, parentNode, children, format, start, count);
84188         }
84189         function writeDelimiter(format) {
84190             switch (format & 60) {
84191                 case 0:
84192                     break;
84193                 case 16:
84194                     writePunctuation(",");
84195                     break;
84196                 case 4:
84197                     writeSpace();
84198                     writePunctuation("|");
84199                     break;
84200                 case 32:
84201                     writeSpace();
84202                     writePunctuation("*");
84203                     writeSpace();
84204                     break;
84205                 case 8:
84206                     writeSpace();
84207                     writePunctuation("&");
84208                     break;
84209             }
84210         }
84211         function emitNodeList(emit, parentNode, children, format, start, count) {
84212             if (start === void 0) { start = 0; }
84213             if (count === void 0) { count = children ? children.length - start : 0; }
84214             var isUndefined = children === undefined;
84215             if (isUndefined && format & 16384) {
84216                 return;
84217             }
84218             var isEmpty = children === undefined || start >= children.length || count === 0;
84219             if (isEmpty && format & 32768) {
84220                 if (onBeforeEmitNodeArray) {
84221                     onBeforeEmitNodeArray(children);
84222                 }
84223                 if (onAfterEmitNodeArray) {
84224                     onAfterEmitNodeArray(children);
84225                 }
84226                 return;
84227             }
84228             if (format & 15360) {
84229                 writePunctuation(getOpeningBracket(format));
84230                 if (isEmpty && !isUndefined) {
84231                     emitTrailingCommentsOfPosition(children.pos, true);
84232                 }
84233             }
84234             if (onBeforeEmitNodeArray) {
84235                 onBeforeEmitNodeArray(children);
84236             }
84237             if (isEmpty) {
84238                 if (format & 1 && !(preserveSourceNewlines && ts.rangeIsOnSingleLine(parentNode, currentSourceFile))) {
84239                     writeLine();
84240                 }
84241                 else if (format & 256 && !(format & 524288)) {
84242                     writeSpace();
84243                 }
84244             }
84245             else {
84246                 var mayEmitInterveningComments = (format & 262144) === 0;
84247                 var shouldEmitInterveningComments = mayEmitInterveningComments;
84248                 var leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children, format);
84249                 if (leadingLineTerminatorCount) {
84250                     writeLine(leadingLineTerminatorCount);
84251                     shouldEmitInterveningComments = false;
84252                 }
84253                 else if (format & 256) {
84254                     writeSpace();
84255                 }
84256                 if (format & 128) {
84257                     increaseIndent();
84258                 }
84259                 var previousSibling = void 0;
84260                 var previousSourceFileTextKind = void 0;
84261                 var shouldDecreaseIndentAfterEmit = false;
84262                 for (var i = 0; i < count; i++) {
84263                     var child = children[start + i];
84264                     if (format & 32) {
84265                         writeLine();
84266                         writeDelimiter(format);
84267                     }
84268                     else if (previousSibling) {
84269                         if (format & 60 && previousSibling.end !== parentNode.end) {
84270                             emitLeadingCommentsOfPosition(previousSibling.end);
84271                         }
84272                         writeDelimiter(format);
84273                         recordBundleFileInternalSectionEnd(previousSourceFileTextKind);
84274                         var separatingLineTerminatorCount = getSeparatingLineTerminatorCount(previousSibling, child, format);
84275                         if (separatingLineTerminatorCount > 0) {
84276                             if ((format & (3 | 128)) === 0) {
84277                                 increaseIndent();
84278                                 shouldDecreaseIndentAfterEmit = true;
84279                             }
84280                             writeLine(separatingLineTerminatorCount);
84281                             shouldEmitInterveningComments = false;
84282                         }
84283                         else if (previousSibling && format & 512) {
84284                             writeSpace();
84285                         }
84286                     }
84287                     previousSourceFileTextKind = recordBundleFileInternalSectionStart(child);
84288                     if (shouldEmitInterveningComments) {
84289                         if (emitTrailingCommentsOfPosition) {
84290                             var commentRange = ts.getCommentRange(child);
84291                             emitTrailingCommentsOfPosition(commentRange.pos);
84292                         }
84293                     }
84294                     else {
84295                         shouldEmitInterveningComments = mayEmitInterveningComments;
84296                     }
84297                     nextListElementPos = child.pos;
84298                     emit(child);
84299                     if (shouldDecreaseIndentAfterEmit) {
84300                         decreaseIndent();
84301                         shouldDecreaseIndentAfterEmit = false;
84302                     }
84303                     previousSibling = child;
84304                 }
84305                 var hasTrailingComma = (format & 64) && children.hasTrailingComma;
84306                 if (format & 16 && hasTrailingComma) {
84307                     writePunctuation(",");
84308                 }
84309                 if (previousSibling && format & 60 && previousSibling.end !== parentNode.end && !(ts.getEmitFlags(previousSibling) & 1024)) {
84310                     emitLeadingCommentsOfPosition(previousSibling.end);
84311                 }
84312                 if (format & 128) {
84313                     decreaseIndent();
84314                 }
84315                 recordBundleFileInternalSectionEnd(previousSourceFileTextKind);
84316                 var closingLineTerminatorCount = getClosingLineTerminatorCount(parentNode, children, format);
84317                 if (closingLineTerminatorCount) {
84318                     writeLine(closingLineTerminatorCount);
84319                 }
84320                 else if (format & (2097152 | 256)) {
84321                     writeSpace();
84322                 }
84323             }
84324             if (onAfterEmitNodeArray) {
84325                 onAfterEmitNodeArray(children);
84326             }
84327             if (format & 15360) {
84328                 if (isEmpty && !isUndefined) {
84329                     emitLeadingCommentsOfPosition(children.end);
84330                 }
84331                 writePunctuation(getClosingBracket(format));
84332             }
84333         }
84334         function writeLiteral(s) {
84335             writer.writeLiteral(s);
84336         }
84337         function writeStringLiteral(s) {
84338             writer.writeStringLiteral(s);
84339         }
84340         function writeBase(s) {
84341             writer.write(s);
84342         }
84343         function writeSymbol(s, sym) {
84344             writer.writeSymbol(s, sym);
84345         }
84346         function writePunctuation(s) {
84347             writer.writePunctuation(s);
84348         }
84349         function writeTrailingSemicolon() {
84350             writer.writeTrailingSemicolon(";");
84351         }
84352         function writeKeyword(s) {
84353             writer.writeKeyword(s);
84354         }
84355         function writeOperator(s) {
84356             writer.writeOperator(s);
84357         }
84358         function writeParameter(s) {
84359             writer.writeParameter(s);
84360         }
84361         function writeComment(s) {
84362             writer.writeComment(s);
84363         }
84364         function writeSpace() {
84365             writer.writeSpace(" ");
84366         }
84367         function writeProperty(s) {
84368             writer.writeProperty(s);
84369         }
84370         function writeLine(count) {
84371             if (count === void 0) { count = 1; }
84372             for (var i = 0; i < count; i++) {
84373                 writer.writeLine(i > 0);
84374             }
84375         }
84376         function increaseIndent() {
84377             writer.increaseIndent();
84378         }
84379         function decreaseIndent() {
84380             writer.decreaseIndent();
84381         }
84382         function writeToken(token, pos, writer, contextNode) {
84383             return !sourceMapsDisabled
84384                 ? emitTokenWithSourceMap(contextNode, token, writer, pos, writeTokenText)
84385                 : writeTokenText(token, writer, pos);
84386         }
84387         function writeTokenNode(node, writer) {
84388             if (onBeforeEmitToken) {
84389                 onBeforeEmitToken(node);
84390             }
84391             writer(ts.tokenToString(node.kind));
84392             if (onAfterEmitToken) {
84393                 onAfterEmitToken(node);
84394             }
84395         }
84396         function writeTokenText(token, writer, pos) {
84397             var tokenString = ts.tokenToString(token);
84398             writer(tokenString);
84399             return pos < 0 ? pos : pos + tokenString.length;
84400         }
84401         function writeLineOrSpace(parentNode, prevChildNode, nextChildNode) {
84402             if (ts.getEmitFlags(parentNode) & 1) {
84403                 writeSpace();
84404             }
84405             else if (preserveSourceNewlines) {
84406                 var lines = getLinesBetweenNodes(parentNode, prevChildNode, nextChildNode);
84407                 if (lines) {
84408                     writeLine(lines);
84409                 }
84410                 else {
84411                     writeSpace();
84412                 }
84413             }
84414             else {
84415                 writeLine();
84416             }
84417         }
84418         function writeLines(text) {
84419             var lines = text.split(/\r\n?|\n/g);
84420             var indentation = ts.guessIndentation(lines);
84421             for (var _a = 0, lines_3 = lines; _a < lines_3.length; _a++) {
84422                 var lineText = lines_3[_a];
84423                 var line = indentation ? lineText.slice(indentation) : lineText;
84424                 if (line.length) {
84425                     writeLine();
84426                     write(line);
84427                 }
84428             }
84429         }
84430         function writeLinesAndIndent(lineCount, writeSpaceIfNotIndenting) {
84431             if (lineCount) {
84432                 increaseIndent();
84433                 writeLine(lineCount);
84434             }
84435             else if (writeSpaceIfNotIndenting) {
84436                 writeSpace();
84437             }
84438         }
84439         function decreaseIndentIf(value1, value2) {
84440             if (value1) {
84441                 decreaseIndent();
84442             }
84443             if (value2) {
84444                 decreaseIndent();
84445             }
84446         }
84447         function getLeadingLineTerminatorCount(parentNode, children, format) {
84448             if (format & 2 || preserveSourceNewlines) {
84449                 if (format & 65536) {
84450                     return 1;
84451                 }
84452                 var firstChild_1 = children[0];
84453                 if (firstChild_1 === undefined) {
84454                     return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
84455                 }
84456                 if (firstChild_1.pos === nextListElementPos) {
84457                     return 0;
84458                 }
84459                 if (firstChild_1.kind === 11) {
84460                     return 0;
84461                 }
84462                 if (!ts.positionIsSynthesized(parentNode.pos) &&
84463                     !ts.nodeIsSynthesized(firstChild_1) &&
84464                     (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) {
84465                     if (preserveSourceNewlines) {
84466                         return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(firstChild_1.pos, parentNode.pos, currentSourceFile, includeComments); });
84467                     }
84468                     return ts.rangeStartPositionsAreOnSameLine(parentNode, firstChild_1, currentSourceFile) ? 0 : 1;
84469                 }
84470                 if (synthesizedNodeStartsOnNewLine(firstChild_1, format)) {
84471                     return 1;
84472                 }
84473             }
84474             return format & 1 ? 1 : 0;
84475         }
84476         function getSeparatingLineTerminatorCount(previousNode, nextNode, format) {
84477             if (format & 2 || preserveSourceNewlines) {
84478                 if (previousNode === undefined || nextNode === undefined) {
84479                     return 0;
84480                 }
84481                 if (nextNode.kind === 11) {
84482                     return 0;
84483                 }
84484                 else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode) && previousNode.parent === nextNode.parent) {
84485                     if (preserveSourceNewlines) {
84486                         return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); });
84487                     }
84488                     return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1;
84489                 }
84490                 else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) {
84491                     return 1;
84492                 }
84493             }
84494             else if (ts.getStartsOnNewLine(nextNode)) {
84495                 return 1;
84496             }
84497             return format & 1 ? 1 : 0;
84498         }
84499         function getClosingLineTerminatorCount(parentNode, children, format) {
84500             if (format & 2 || preserveSourceNewlines) {
84501                 if (format & 65536) {
84502                     return 1;
84503                 }
84504                 var lastChild = ts.lastOrUndefined(children);
84505                 if (lastChild === undefined) {
84506                     return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
84507                 }
84508                 if (!ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) {
84509                     if (preserveSourceNewlines) {
84510                         var end_2 = ts.isNodeArray(children) && !ts.positionIsSynthesized(children.end) ? children.end : lastChild.end;
84511                         return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_2, parentNode.end, currentSourceFile, includeComments); });
84512                     }
84513                     return ts.rangeEndPositionsAreOnSameLine(parentNode, lastChild, currentSourceFile) ? 0 : 1;
84514                 }
84515                 if (synthesizedNodeStartsOnNewLine(lastChild, format)) {
84516                     return 1;
84517                 }
84518             }
84519             if (format & 1 && !(format & 131072)) {
84520                 return 1;
84521             }
84522             return 0;
84523         }
84524         function getEffectiveLines(getLineDifference) {
84525             ts.Debug.assert(!!preserveSourceNewlines);
84526             var lines = getLineDifference(true);
84527             if (lines === 0) {
84528                 return getLineDifference(false);
84529             }
84530             return lines;
84531         }
84532         function writeLineSeparatorsAndIndentBefore(node, parent) {
84533             var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], 0);
84534             if (leadingNewlines) {
84535                 writeLinesAndIndent(leadingNewlines, false);
84536             }
84537             return !!leadingNewlines;
84538         }
84539         function writeLineSeparatorsAfter(node, parent) {
84540             var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, [node], 0);
84541             if (trailingNewlines) {
84542                 writeLine(trailingNewlines);
84543             }
84544         }
84545         function synthesizedNodeStartsOnNewLine(node, format) {
84546             if (ts.nodeIsSynthesized(node)) {
84547                 var startsOnNewLine = ts.getStartsOnNewLine(node);
84548                 if (startsOnNewLine === undefined) {
84549                     return (format & 65536) !== 0;
84550                 }
84551                 return startsOnNewLine;
84552             }
84553             return (format & 65536) !== 0;
84554         }
84555         function getLinesBetweenNodes(parent, node1, node2) {
84556             if (ts.getEmitFlags(parent) & 131072) {
84557                 return 0;
84558             }
84559             parent = skipSynthesizedParentheses(parent);
84560             node1 = skipSynthesizedParentheses(node1);
84561             node2 = skipSynthesizedParentheses(node2);
84562             if (ts.getStartsOnNewLine(node2)) {
84563                 return 1;
84564             }
84565             if (!ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
84566                 if (preserveSourceNewlines) {
84567                     return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(node1, node2, currentSourceFile, includeComments); });
84568                 }
84569                 return ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile) ? 0 : 1;
84570             }
84571             return 0;
84572         }
84573         function isEmptyBlock(block) {
84574             return block.statements.length === 0
84575                 && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile);
84576         }
84577         function skipSynthesizedParentheses(node) {
84578             while (node.kind === 207 && ts.nodeIsSynthesized(node)) {
84579                 node = node.expression;
84580             }
84581             return node;
84582         }
84583         function getTextOfNode(node, includeTrivia) {
84584             if (ts.isGeneratedIdentifier(node)) {
84585                 return generateName(node);
84586             }
84587             else if ((ts.isIdentifier(node) || ts.isPrivateIdentifier(node)) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) {
84588                 return ts.idText(node);
84589             }
84590             else if (node.kind === 10 && node.textSourceNode) {
84591                 return getTextOfNode(node.textSourceNode, includeTrivia);
84592             }
84593             else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) {
84594                 return node.text;
84595             }
84596             return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia);
84597         }
84598         function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) {
84599             if (node.kind === 10 && node.textSourceNode) {
84600                 var textSourceNode = node.textSourceNode;
84601                 if (ts.isIdentifier(textSourceNode) || ts.isNumericLiteral(textSourceNode)) {
84602                     var text = ts.isNumericLiteral(textSourceNode) ? textSourceNode.text : getTextOfNode(textSourceNode);
84603                     return jsxAttributeEscape ? "\"" + ts.escapeJsxAttributeString(text) + "\"" :
84604                         neverAsciiEscape || (ts.getEmitFlags(node) & 16777216) ? "\"" + ts.escapeString(text) + "\"" :
84605                             "\"" + ts.escapeNonAsciiString(text) + "\"";
84606                 }
84607                 else {
84608                     return getLiteralTextOfNode(textSourceNode, neverAsciiEscape, jsxAttributeEscape);
84609                 }
84610             }
84611             var flags = (neverAsciiEscape ? 1 : 0)
84612                 | (jsxAttributeEscape ? 2 : 0)
84613                 | (printerOptions.terminateUnterminatedLiterals ? 4 : 0);
84614             return ts.getLiteralText(node, currentSourceFile, flags);
84615         }
84616         function pushNameGenerationScope(node) {
84617             if (node && ts.getEmitFlags(node) & 524288) {
84618                 return;
84619             }
84620             tempFlagsStack.push(tempFlags);
84621             tempFlags = 0;
84622             reservedNamesStack.push(reservedNames);
84623         }
84624         function popNameGenerationScope(node) {
84625             if (node && ts.getEmitFlags(node) & 524288) {
84626                 return;
84627             }
84628             tempFlags = tempFlagsStack.pop();
84629             reservedNames = reservedNamesStack.pop();
84630         }
84631         function reserveNameInNestedScopes(name) {
84632             if (!reservedNames || reservedNames === ts.lastOrUndefined(reservedNamesStack)) {
84633                 reservedNames = new ts.Set();
84634             }
84635             reservedNames.add(name);
84636         }
84637         function generateNames(node) {
84638             if (!node)
84639                 return;
84640             switch (node.kind) {
84641                 case 230:
84642                     ts.forEach(node.statements, generateNames);
84643                     break;
84644                 case 245:
84645                 case 243:
84646                 case 235:
84647                 case 236:
84648                     generateNames(node.statement);
84649                     break;
84650                 case 234:
84651                     generateNames(node.thenStatement);
84652                     generateNames(node.elseStatement);
84653                     break;
84654                 case 237:
84655                 case 239:
84656                 case 238:
84657                     generateNames(node.initializer);
84658                     generateNames(node.statement);
84659                     break;
84660                 case 244:
84661                     generateNames(node.caseBlock);
84662                     break;
84663                 case 258:
84664                     ts.forEach(node.clauses, generateNames);
84665                     break;
84666                 case 284:
84667                 case 285:
84668                     ts.forEach(node.statements, generateNames);
84669                     break;
84670                 case 247:
84671                     generateNames(node.tryBlock);
84672                     generateNames(node.catchClause);
84673                     generateNames(node.finallyBlock);
84674                     break;
84675                 case 287:
84676                     generateNames(node.variableDeclaration);
84677                     generateNames(node.block);
84678                     break;
84679                 case 232:
84680                     generateNames(node.declarationList);
84681                     break;
84682                 case 250:
84683                     ts.forEach(node.declarations, generateNames);
84684                     break;
84685                 case 249:
84686                 case 160:
84687                 case 198:
84688                 case 252:
84689                     generateNameIfNeeded(node.name);
84690                     break;
84691                 case 251:
84692                     generateNameIfNeeded(node.name);
84693                     if (ts.getEmitFlags(node) & 524288) {
84694                         ts.forEach(node.parameters, generateNames);
84695                         generateNames(node.body);
84696                     }
84697                     break;
84698                 case 196:
84699                 case 197:
84700                     ts.forEach(node.elements, generateNames);
84701                     break;
84702                 case 261:
84703                     generateNames(node.importClause);
84704                     break;
84705                 case 262:
84706                     generateNameIfNeeded(node.name);
84707                     generateNames(node.namedBindings);
84708                     break;
84709                 case 263:
84710                     generateNameIfNeeded(node.name);
84711                     break;
84712                 case 269:
84713                     generateNameIfNeeded(node.name);
84714                     break;
84715                 case 264:
84716                     ts.forEach(node.elements, generateNames);
84717                     break;
84718                 case 265:
84719                     generateNameIfNeeded(node.propertyName || node.name);
84720                     break;
84721             }
84722         }
84723         function generateMemberNames(node) {
84724             if (!node)
84725                 return;
84726             switch (node.kind) {
84727                 case 288:
84728                 case 289:
84729                 case 163:
84730                 case 165:
84731                 case 167:
84732                 case 168:
84733                     generateNameIfNeeded(node.name);
84734                     break;
84735             }
84736         }
84737         function generateNameIfNeeded(name) {
84738             if (name) {
84739                 if (ts.isGeneratedIdentifier(name)) {
84740                     generateName(name);
84741                 }
84742                 else if (ts.isBindingPattern(name)) {
84743                     generateNames(name);
84744                 }
84745             }
84746         }
84747         function generateName(name) {
84748             if ((name.autoGenerateFlags & 7) === 4) {
84749                 return generateNameCached(getNodeForGeneratedName(name), name.autoGenerateFlags);
84750             }
84751             else {
84752                 var autoGenerateId = name.autoGenerateId;
84753                 return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = makeName(name));
84754             }
84755         }
84756         function generateNameCached(node, flags) {
84757             var nodeId = ts.getNodeId(node);
84758             return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = generateNameForNode(node, flags));
84759         }
84760         function isUniqueName(name) {
84761             return isFileLevelUniqueName(name)
84762                 && !generatedNames.has(name)
84763                 && !(reservedNames && reservedNames.has(name));
84764         }
84765         function isFileLevelUniqueName(name) {
84766             return currentSourceFile ? ts.isFileLevelUniqueName(currentSourceFile, name, hasGlobalName) : true;
84767         }
84768         function isUniqueLocalName(name, container) {
84769             for (var node = container; ts.isNodeDescendantOf(node, container); node = node.nextContainer) {
84770                 if (node.locals) {
84771                     var local = node.locals.get(ts.escapeLeadingUnderscores(name));
84772                     if (local && local.flags & (111551 | 1048576 | 2097152)) {
84773                         return false;
84774                     }
84775                 }
84776             }
84777             return true;
84778         }
84779         function makeTempVariableName(flags, reservedInNestedScopes) {
84780             if (flags && !(tempFlags & flags)) {
84781                 var name = flags === 268435456 ? "_i" : "_n";
84782                 if (isUniqueName(name)) {
84783                     tempFlags |= flags;
84784                     if (reservedInNestedScopes) {
84785                         reserveNameInNestedScopes(name);
84786                     }
84787                     return name;
84788                 }
84789             }
84790             while (true) {
84791                 var count = tempFlags & 268435455;
84792                 tempFlags++;
84793                 if (count !== 8 && count !== 13) {
84794                     var name = count < 26
84795                         ? "_" + String.fromCharCode(97 + count)
84796                         : "_" + (count - 26);
84797                     if (isUniqueName(name)) {
84798                         if (reservedInNestedScopes) {
84799                             reserveNameInNestedScopes(name);
84800                         }
84801                         return name;
84802                     }
84803                 }
84804             }
84805         }
84806         function makeUniqueName(baseName, checkFn, optimistic, scoped) {
84807             if (checkFn === void 0) { checkFn = isUniqueName; }
84808             if (optimistic) {
84809                 if (checkFn(baseName)) {
84810                     if (scoped) {
84811                         reserveNameInNestedScopes(baseName);
84812                     }
84813                     else {
84814                         generatedNames.add(baseName);
84815                     }
84816                     return baseName;
84817                 }
84818             }
84819             if (baseName.charCodeAt(baseName.length - 1) !== 95) {
84820                 baseName += "_";
84821             }
84822             var i = 1;
84823             while (true) {
84824                 var generatedName = baseName + i;
84825                 if (checkFn(generatedName)) {
84826                     if (scoped) {
84827                         reserveNameInNestedScopes(generatedName);
84828                     }
84829                     else {
84830                         generatedNames.add(generatedName);
84831                     }
84832                     return generatedName;
84833                 }
84834                 i++;
84835             }
84836         }
84837         function makeFileLevelOptimisticUniqueName(name) {
84838             return makeUniqueName(name, isFileLevelUniqueName, true);
84839         }
84840         function generateNameForModuleOrEnum(node) {
84841             var name = getTextOfNode(node.name);
84842             return isUniqueLocalName(name, node) ? name : makeUniqueName(name);
84843         }
84844         function generateNameForImportOrExportDeclaration(node) {
84845             var expr = ts.getExternalModuleName(node);
84846             var baseName = ts.isStringLiteral(expr) ?
84847                 ts.makeIdentifierFromModuleName(expr.text) : "module";
84848             return makeUniqueName(baseName);
84849         }
84850         function generateNameForExportDefault() {
84851             return makeUniqueName("default");
84852         }
84853         function generateNameForClassExpression() {
84854             return makeUniqueName("class");
84855         }
84856         function generateNameForMethodOrAccessor(node) {
84857             if (ts.isIdentifier(node.name)) {
84858                 return generateNameCached(node.name);
84859             }
84860             return makeTempVariableName(0);
84861         }
84862         function generateNameForNode(node, flags) {
84863             switch (node.kind) {
84864                 case 78:
84865                     return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16), !!(flags & 8));
84866                 case 256:
84867                 case 255:
84868                     return generateNameForModuleOrEnum(node);
84869                 case 261:
84870                 case 267:
84871                     return generateNameForImportOrExportDeclaration(node);
84872                 case 251:
84873                 case 252:
84874                 case 266:
84875                     return generateNameForExportDefault();
84876                 case 221:
84877                     return generateNameForClassExpression();
84878                 case 165:
84879                 case 167:
84880                 case 168:
84881                     return generateNameForMethodOrAccessor(node);
84882                 case 158:
84883                     return makeTempVariableName(0, true);
84884                 default:
84885                     return makeTempVariableName(0);
84886             }
84887         }
84888         function makeName(name) {
84889             switch (name.autoGenerateFlags & 7) {
84890                 case 1:
84891                     return makeTempVariableName(0, !!(name.autoGenerateFlags & 8));
84892                 case 2:
84893                     return makeTempVariableName(268435456, !!(name.autoGenerateFlags & 8));
84894                 case 3:
84895                     return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16), !!(name.autoGenerateFlags & 8));
84896             }
84897             return ts.Debug.fail("Unsupported GeneratedIdentifierKind.");
84898         }
84899         function getNodeForGeneratedName(name) {
84900             var autoGenerateId = name.autoGenerateId;
84901             var node = name;
84902             var original = node.original;
84903             while (original) {
84904                 node = original;
84905                 if (ts.isIdentifier(node)
84906                     && !!(node.autoGenerateFlags & 4)
84907                     && node.autoGenerateId !== autoGenerateId) {
84908                     break;
84909                 }
84910                 original = node.original;
84911             }
84912             return node;
84913         }
84914         function pipelineEmitWithComments(hint, node) {
84915             ts.Debug.assert(lastNode === node || lastSubstitution === node);
84916             enterComment();
84917             hasWrittenComment = false;
84918             var emitFlags = ts.getEmitFlags(node);
84919             var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end;
84920             var isEmittedNode = node.kind !== 335;
84921             var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0 || node.kind === 11;
84922             var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0 || node.kind === 11;
84923             var savedContainerPos = containerPos;
84924             var savedContainerEnd = containerEnd;
84925             var savedDeclarationListContainerEnd = declarationListContainerEnd;
84926             if ((pos > 0 || end > 0) && pos !== end) {
84927                 if (!skipLeadingComments) {
84928                     emitLeadingComments(pos, isEmittedNode);
84929                 }
84930                 if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512) !== 0)) {
84931                     containerPos = pos;
84932                 }
84933                 if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024) !== 0)) {
84934                     containerEnd = end;
84935                     if (node.kind === 250) {
84936                         declarationListContainerEnd = end;
84937                     }
84938                 }
84939             }
84940             ts.forEach(ts.getSyntheticLeadingComments(node), emitLeadingSynthesizedComment);
84941             exitComment();
84942             var pipelinePhase = getNextPipelinePhase(2, hint, node);
84943             if (emitFlags & 2048) {
84944                 commentsDisabled = true;
84945                 pipelinePhase(hint, node);
84946                 commentsDisabled = false;
84947             }
84948             else {
84949                 pipelinePhase(hint, node);
84950             }
84951             enterComment();
84952             ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment);
84953             if ((pos > 0 || end > 0) && pos !== end) {
84954                 containerPos = savedContainerPos;
84955                 containerEnd = savedContainerEnd;
84956                 declarationListContainerEnd = savedDeclarationListContainerEnd;
84957                 if (!skipTrailingComments && isEmittedNode) {
84958                     emitTrailingComments(end);
84959                 }
84960             }
84961             exitComment();
84962             ts.Debug.assert(lastNode === node || lastSubstitution === node);
84963         }
84964         function emitLeadingSynthesizedComment(comment) {
84965             if (comment.hasLeadingNewline || comment.kind === 2) {
84966                 writer.writeLine();
84967             }
84968             writeSynthesizedComment(comment);
84969             if (comment.hasTrailingNewLine || comment.kind === 2) {
84970                 writer.writeLine();
84971             }
84972             else {
84973                 writer.writeSpace(" ");
84974             }
84975         }
84976         function emitTrailingSynthesizedComment(comment) {
84977             if (!writer.isAtStartOfLine()) {
84978                 writer.writeSpace(" ");
84979             }
84980             writeSynthesizedComment(comment);
84981             if (comment.hasTrailingNewLine) {
84982                 writer.writeLine();
84983             }
84984         }
84985         function writeSynthesizedComment(comment) {
84986             var text = formatSynthesizedComment(comment);
84987             var lineMap = comment.kind === 3 ? ts.computeLineStarts(text) : undefined;
84988             ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine);
84989         }
84990         function formatSynthesizedComment(comment) {
84991             return comment.kind === 3
84992                 ? "/*" + comment.text + "*/"
84993                 : "//" + comment.text;
84994         }
84995         function emitBodyWithDetachedComments(node, detachedRange, emitCallback) {
84996             enterComment();
84997             var pos = detachedRange.pos, end = detachedRange.end;
84998             var emitFlags = ts.getEmitFlags(node);
84999             var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0;
85000             var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024) !== 0;
85001             if (!skipLeadingComments) {
85002                 emitDetachedCommentsAndUpdateCommentsInfo(detachedRange);
85003             }
85004             exitComment();
85005             if (emitFlags & 2048 && !commentsDisabled) {
85006                 commentsDisabled = true;
85007                 emitCallback(node);
85008                 commentsDisabled = false;
85009             }
85010             else {
85011                 emitCallback(node);
85012             }
85013             enterComment();
85014             if (!skipTrailingComments) {
85015                 emitLeadingComments(detachedRange.end, true);
85016                 if (hasWrittenComment && !writer.isAtStartOfLine()) {
85017                     writer.writeLine();
85018                 }
85019             }
85020             exitComment();
85021         }
85022         function emitLeadingComments(pos, isEmittedNode) {
85023             hasWrittenComment = false;
85024             if (isEmittedNode) {
85025                 if (pos === 0 && (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.isDeclarationFile)) {
85026                     forEachLeadingCommentToEmit(pos, emitNonTripleSlashLeadingComment);
85027                 }
85028                 else {
85029                     forEachLeadingCommentToEmit(pos, emitLeadingComment);
85030                 }
85031             }
85032             else if (pos === 0) {
85033                 forEachLeadingCommentToEmit(pos, emitTripleSlashLeadingComment);
85034             }
85035         }
85036         function emitTripleSlashLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
85037             if (isTripleSlashComment(commentPos, commentEnd)) {
85038                 emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos);
85039             }
85040         }
85041         function emitNonTripleSlashLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
85042             if (!isTripleSlashComment(commentPos, commentEnd)) {
85043                 emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos);
85044             }
85045         }
85046         function shouldWriteComment(text, pos) {
85047             if (printerOptions.onlyPrintJsDocStyle) {
85048                 return (ts.isJSDocLikeText(text, pos) || ts.isPinnedComment(text, pos));
85049             }
85050             return true;
85051         }
85052         function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
85053             if (!shouldWriteComment(currentSourceFile.text, commentPos))
85054                 return;
85055             if (!hasWrittenComment) {
85056                 ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos);
85057                 hasWrittenComment = true;
85058             }
85059             emitPos(commentPos);
85060             ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
85061             emitPos(commentEnd);
85062             if (hasTrailingNewLine) {
85063                 writer.writeLine();
85064             }
85065             else if (kind === 3) {
85066                 writer.writeSpace(" ");
85067             }
85068         }
85069         function emitLeadingCommentsOfPosition(pos) {
85070             if (commentsDisabled || pos === -1) {
85071                 return;
85072             }
85073             emitLeadingComments(pos, true);
85074         }
85075         function emitTrailingComments(pos) {
85076             forEachTrailingCommentToEmit(pos, emitTrailingComment);
85077         }
85078         function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) {
85079             if (!shouldWriteComment(currentSourceFile.text, commentPos))
85080                 return;
85081             if (!writer.isAtStartOfLine()) {
85082                 writer.writeSpace(" ");
85083             }
85084             emitPos(commentPos);
85085             ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
85086             emitPos(commentEnd);
85087             if (hasTrailingNewLine) {
85088                 writer.writeLine();
85089             }
85090         }
85091         function emitTrailingCommentsOfPosition(pos, prefixSpace) {
85092             if (commentsDisabled) {
85093                 return;
85094             }
85095             enterComment();
85096             forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : emitTrailingCommentOfPosition);
85097             exitComment();
85098         }
85099         function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) {
85100             emitPos(commentPos);
85101             ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
85102             emitPos(commentEnd);
85103             if (hasTrailingNewLine) {
85104                 writer.writeLine();
85105             }
85106             else {
85107                 writer.writeSpace(" ");
85108             }
85109         }
85110         function forEachLeadingCommentToEmit(pos, cb) {
85111             if (currentSourceFile && (containerPos === -1 || pos !== containerPos)) {
85112                 if (hasDetachedComments(pos)) {
85113                     forEachLeadingCommentWithoutDetachedComments(cb);
85114                 }
85115                 else {
85116                     ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, pos);
85117                 }
85118             }
85119         }
85120         function forEachTrailingCommentToEmit(end, cb) {
85121             if (currentSourceFile && (containerEnd === -1 || (end !== containerEnd && end !== declarationListContainerEnd))) {
85122                 ts.forEachTrailingCommentRange(currentSourceFile.text, end, cb);
85123             }
85124         }
85125         function hasDetachedComments(pos) {
85126             return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos;
85127         }
85128         function forEachLeadingCommentWithoutDetachedComments(cb) {
85129             var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos;
85130             if (detachedCommentsInfo.length - 1) {
85131                 detachedCommentsInfo.pop();
85132             }
85133             else {
85134                 detachedCommentsInfo = undefined;
85135             }
85136             ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, pos);
85137         }
85138         function emitDetachedCommentsAndUpdateCommentsInfo(range) {
85139             var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled);
85140             if (currentDetachedCommentInfo) {
85141                 if (detachedCommentsInfo) {
85142                     detachedCommentsInfo.push(currentDetachedCommentInfo);
85143                 }
85144                 else {
85145                     detachedCommentsInfo = [currentDetachedCommentInfo];
85146                 }
85147             }
85148         }
85149         function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) {
85150             if (!shouldWriteComment(currentSourceFile.text, commentPos))
85151                 return;
85152             emitPos(commentPos);
85153             ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine);
85154             emitPos(commentEnd);
85155         }
85156         function isTripleSlashComment(commentPos, commentEnd) {
85157             return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
85158         }
85159         function getParsedSourceMap(node) {
85160             if (node.parsedSourceMap === undefined && node.sourceMapText !== undefined) {
85161                 node.parsedSourceMap = ts.tryParseRawSourceMap(node.sourceMapText) || false;
85162             }
85163             return node.parsedSourceMap || undefined;
85164         }
85165         function pipelineEmitWithSourceMap(hint, node) {
85166             ts.Debug.assert(lastNode === node || lastSubstitution === node);
85167             var pipelinePhase = getNextPipelinePhase(3, hint, node);
85168             if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) {
85169                 pipelinePhase(hint, node);
85170             }
85171             else if (ts.isUnparsedNode(node)) {
85172                 var parsed = getParsedSourceMap(node.parent);
85173                 if (parsed && sourceMapGenerator) {
85174                     sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.parent.sourceMapPath, node.parent.getLineAndCharacterOfPosition(node.pos), node.parent.getLineAndCharacterOfPosition(node.end));
85175                 }
85176                 pipelinePhase(hint, node);
85177             }
85178             else {
85179                 var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b;
85180                 var emitFlags = ts.getEmitFlags(node);
85181                 if (node.kind !== 335
85182                     && (emitFlags & 16) === 0
85183                     && pos >= 0) {
85184                     emitSourcePos(source, skipSourceTrivia(source, pos));
85185                 }
85186                 if (emitFlags & 64) {
85187                     sourceMapsDisabled = true;
85188                     pipelinePhase(hint, node);
85189                     sourceMapsDisabled = false;
85190                 }
85191                 else {
85192                     pipelinePhase(hint, node);
85193                 }
85194                 if (node.kind !== 335
85195                     && (emitFlags & 32) === 0
85196                     && end >= 0) {
85197                     emitSourcePos(source, end);
85198                 }
85199             }
85200             ts.Debug.assert(lastNode === node || lastSubstitution === node);
85201         }
85202         function skipSourceTrivia(source, pos) {
85203             return source.skipTrivia ? source.skipTrivia(pos) : ts.skipTrivia(source.text, pos);
85204         }
85205         function emitPos(pos) {
85206             if (sourceMapsDisabled || ts.positionIsSynthesized(pos) || isJsonSourceMapSource(sourceMapSource)) {
85207                 return;
85208             }
85209             var _a = ts.getLineAndCharacterOfPosition(sourceMapSource, pos), sourceLine = _a.line, sourceCharacter = _a.character;
85210             sourceMapGenerator.addMapping(writer.getLine(), writer.getColumn(), sourceMapSourceIndex, sourceLine, sourceCharacter, undefined);
85211         }
85212         function emitSourcePos(source, pos) {
85213             if (source !== sourceMapSource) {
85214                 var savedSourceMapSource = sourceMapSource;
85215                 var savedSourceMapSourceIndex = sourceMapSourceIndex;
85216                 setSourceMapSource(source);
85217                 emitPos(pos);
85218                 resetSourceMapSource(savedSourceMapSource, savedSourceMapSourceIndex);
85219             }
85220             else {
85221                 emitPos(pos);
85222             }
85223         }
85224         function emitTokenWithSourceMap(node, token, writer, tokenPos, emitCallback) {
85225             if (sourceMapsDisabled || node && ts.isInJsonFile(node)) {
85226                 return emitCallback(token, writer, tokenPos);
85227             }
85228             var emitNode = node && node.emitNode;
85229             var emitFlags = emitNode && emitNode.flags || 0;
85230             var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token];
85231             var source = range && range.source || sourceMapSource;
85232             tokenPos = skipSourceTrivia(source, range ? range.pos : tokenPos);
85233             if ((emitFlags & 128) === 0 && tokenPos >= 0) {
85234                 emitSourcePos(source, tokenPos);
85235             }
85236             tokenPos = emitCallback(token, writer, tokenPos);
85237             if (range)
85238                 tokenPos = range.end;
85239             if ((emitFlags & 256) === 0 && tokenPos >= 0) {
85240                 emitSourcePos(source, tokenPos);
85241             }
85242             return tokenPos;
85243         }
85244         function setSourceMapSource(source) {
85245             if (sourceMapsDisabled) {
85246                 return;
85247             }
85248             sourceMapSource = source;
85249             if (source === mostRecentlyAddedSourceMapSource) {
85250                 sourceMapSourceIndex = mostRecentlyAddedSourceMapSourceIndex;
85251                 return;
85252             }
85253             if (isJsonSourceMapSource(source)) {
85254                 return;
85255             }
85256             sourceMapSourceIndex = sourceMapGenerator.addSource(source.fileName);
85257             if (printerOptions.inlineSources) {
85258                 sourceMapGenerator.setSourceContent(sourceMapSourceIndex, source.text);
85259             }
85260             mostRecentlyAddedSourceMapSource = source;
85261             mostRecentlyAddedSourceMapSourceIndex = sourceMapSourceIndex;
85262         }
85263         function resetSourceMapSource(source, sourceIndex) {
85264             sourceMapSource = source;
85265             sourceMapSourceIndex = sourceIndex;
85266         }
85267         function isJsonSourceMapSource(sourceFile) {
85268             return ts.fileExtensionIs(sourceFile.fileName, ".json");
85269         }
85270     }
85271     ts.createPrinter = createPrinter;
85272     function createBracketsMap() {
85273         var brackets = [];
85274         brackets[1024] = ["{", "}"];
85275         brackets[2048] = ["(", ")"];
85276         brackets[4096] = ["<", ">"];
85277         brackets[8192] = ["[", "]"];
85278         return brackets;
85279     }
85280     function getOpeningBracket(format) {
85281         return brackets[format & 15360][0];
85282     }
85283     function getClosingBracket(format) {
85284         return brackets[format & 15360][1];
85285     }
85286 })(ts || (ts = {}));
85287 var ts;
85288 (function (ts) {
85289     function createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensitiveFileNames) {
85290         if (!host.getDirectories || !host.readDirectory) {
85291             return undefined;
85292         }
85293         var cachedReadDirectoryResult = new ts.Map();
85294         var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
85295         return {
85296             useCaseSensitiveFileNames: useCaseSensitiveFileNames,
85297             fileExists: fileExists,
85298             readFile: function (path, encoding) { return host.readFile(path, encoding); },
85299             directoryExists: host.directoryExists && directoryExists,
85300             getDirectories: getDirectories,
85301             readDirectory: readDirectory,
85302             createDirectory: host.createDirectory && createDirectory,
85303             writeFile: host.writeFile && writeFile,
85304             addOrDeleteFileOrDirectory: addOrDeleteFileOrDirectory,
85305             addOrDeleteFile: addOrDeleteFile,
85306             clearCache: clearCache,
85307             realpath: host.realpath && realpath
85308         };
85309         function toPath(fileName) {
85310             return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
85311         }
85312         function getCachedFileSystemEntries(rootDirPath) {
85313             return cachedReadDirectoryResult.get(ts.ensureTrailingDirectorySeparator(rootDirPath));
85314         }
85315         function getCachedFileSystemEntriesForBaseDir(path) {
85316             return getCachedFileSystemEntries(ts.getDirectoryPath(path));
85317         }
85318         function getBaseNameOfFileName(fileName) {
85319             return ts.getBaseFileName(ts.normalizePath(fileName));
85320         }
85321         function createCachedFileSystemEntries(rootDir, rootDirPath) {
85322             var resultFromHost = {
85323                 files: ts.map(host.readDirectory(rootDir, undefined, undefined, ["*.*"]), getBaseNameOfFileName) || [],
85324                 directories: host.getDirectories(rootDir) || []
85325             };
85326             cachedReadDirectoryResult.set(ts.ensureTrailingDirectorySeparator(rootDirPath), resultFromHost);
85327             return resultFromHost;
85328         }
85329         function tryReadDirectory(rootDir, rootDirPath) {
85330             rootDirPath = ts.ensureTrailingDirectorySeparator(rootDirPath);
85331             var cachedResult = getCachedFileSystemEntries(rootDirPath);
85332             if (cachedResult) {
85333                 return cachedResult;
85334             }
85335             try {
85336                 return createCachedFileSystemEntries(rootDir, rootDirPath);
85337             }
85338             catch (_e) {
85339                 ts.Debug.assert(!cachedReadDirectoryResult.has(ts.ensureTrailingDirectorySeparator(rootDirPath)));
85340                 return undefined;
85341             }
85342         }
85343         function fileNameEqual(name1, name2) {
85344             return getCanonicalFileName(name1) === getCanonicalFileName(name2);
85345         }
85346         function hasEntry(entries, name) {
85347             return ts.some(entries, function (file) { return fileNameEqual(file, name); });
85348         }
85349         function updateFileSystemEntry(entries, baseName, isValid) {
85350             if (hasEntry(entries, baseName)) {
85351                 if (!isValid) {
85352                     return ts.filterMutate(entries, function (entry) { return !fileNameEqual(entry, baseName); });
85353                 }
85354             }
85355             else if (isValid) {
85356                 return entries.push(baseName);
85357             }
85358         }
85359         function writeFile(fileName, data, writeByteOrderMark) {
85360             var path = toPath(fileName);
85361             var result = getCachedFileSystemEntriesForBaseDir(path);
85362             if (result) {
85363                 updateFilesOfFileSystemEntry(result, getBaseNameOfFileName(fileName), true);
85364             }
85365             return host.writeFile(fileName, data, writeByteOrderMark);
85366         }
85367         function fileExists(fileName) {
85368             var path = toPath(fileName);
85369             var result = getCachedFileSystemEntriesForBaseDir(path);
85370             return result && hasEntry(result.files, getBaseNameOfFileName(fileName)) ||
85371                 host.fileExists(fileName);
85372         }
85373         function directoryExists(dirPath) {
85374             var path = toPath(dirPath);
85375             return cachedReadDirectoryResult.has(ts.ensureTrailingDirectorySeparator(path)) || host.directoryExists(dirPath);
85376         }
85377         function createDirectory(dirPath) {
85378             var path = toPath(dirPath);
85379             var result = getCachedFileSystemEntriesForBaseDir(path);
85380             var baseFileName = getBaseNameOfFileName(dirPath);
85381             if (result) {
85382                 updateFileSystemEntry(result.directories, baseFileName, true);
85383             }
85384             host.createDirectory(dirPath);
85385         }
85386         function getDirectories(rootDir) {
85387             var rootDirPath = toPath(rootDir);
85388             var result = tryReadDirectory(rootDir, rootDirPath);
85389             if (result) {
85390                 return result.directories.slice();
85391             }
85392             return host.getDirectories(rootDir);
85393         }
85394         function readDirectory(rootDir, extensions, excludes, includes, depth) {
85395             var rootDirPath = toPath(rootDir);
85396             var result = tryReadDirectory(rootDir, rootDirPath);
85397             if (result) {
85398                 return ts.matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath);
85399             }
85400             return host.readDirectory(rootDir, extensions, excludes, includes, depth);
85401             function getFileSystemEntries(dir) {
85402                 var path = toPath(dir);
85403                 if (path === rootDirPath) {
85404                     return result;
85405                 }
85406                 return tryReadDirectory(dir, path) || ts.emptyFileSystemEntries;
85407             }
85408         }
85409         function realpath(s) {
85410             return host.realpath ? host.realpath(s) : s;
85411         }
85412         function addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath) {
85413             var existingResult = getCachedFileSystemEntries(fileOrDirectoryPath);
85414             if (existingResult) {
85415                 clearCache();
85416                 return undefined;
85417             }
85418             var parentResult = getCachedFileSystemEntriesForBaseDir(fileOrDirectoryPath);
85419             if (!parentResult) {
85420                 return undefined;
85421             }
85422             if (!host.directoryExists) {
85423                 clearCache();
85424                 return undefined;
85425             }
85426             var baseName = getBaseNameOfFileName(fileOrDirectory);
85427             var fsQueryResult = {
85428                 fileExists: host.fileExists(fileOrDirectoryPath),
85429                 directoryExists: host.directoryExists(fileOrDirectoryPath)
85430             };
85431             if (fsQueryResult.directoryExists || hasEntry(parentResult.directories, baseName)) {
85432                 clearCache();
85433             }
85434             else {
85435                 updateFilesOfFileSystemEntry(parentResult, baseName, fsQueryResult.fileExists);
85436             }
85437             return fsQueryResult;
85438         }
85439         function addOrDeleteFile(fileName, filePath, eventKind) {
85440             if (eventKind === ts.FileWatcherEventKind.Changed) {
85441                 return;
85442             }
85443             var parentResult = getCachedFileSystemEntriesForBaseDir(filePath);
85444             if (parentResult) {
85445                 updateFilesOfFileSystemEntry(parentResult, getBaseNameOfFileName(fileName), eventKind === ts.FileWatcherEventKind.Created);
85446             }
85447         }
85448         function updateFilesOfFileSystemEntry(parentResult, baseName, fileExists) {
85449             updateFileSystemEntry(parentResult.files, baseName, fileExists);
85450         }
85451         function clearCache() {
85452             cachedReadDirectoryResult.clear();
85453         }
85454     }
85455     ts.createCachedDirectoryStructureHost = createCachedDirectoryStructureHost;
85456     var ConfigFileProgramReloadLevel;
85457     (function (ConfigFileProgramReloadLevel) {
85458         ConfigFileProgramReloadLevel[ConfigFileProgramReloadLevel["None"] = 0] = "None";
85459         ConfigFileProgramReloadLevel[ConfigFileProgramReloadLevel["Partial"] = 1] = "Partial";
85460         ConfigFileProgramReloadLevel[ConfigFileProgramReloadLevel["Full"] = 2] = "Full";
85461     })(ConfigFileProgramReloadLevel = ts.ConfigFileProgramReloadLevel || (ts.ConfigFileProgramReloadLevel = {}));
85462     function updateMissingFilePathsWatch(program, missingFileWatches, createMissingFileWatch) {
85463         var missingFilePaths = program.getMissingFilePaths();
85464         var newMissingFilePathMap = ts.arrayToMap(missingFilePaths, ts.identity, ts.returnTrue);
85465         ts.mutateMap(missingFileWatches, newMissingFilePathMap, {
85466             createNewValue: createMissingFileWatch,
85467             onDeleteValue: ts.closeFileWatcher
85468         });
85469     }
85470     ts.updateMissingFilePathsWatch = updateMissingFilePathsWatch;
85471     function updateWatchingWildcardDirectories(existingWatchedForWildcards, wildcardDirectories, watchDirectory) {
85472         ts.mutateMap(existingWatchedForWildcards, wildcardDirectories, {
85473             createNewValue: createWildcardDirectoryWatcher,
85474             onDeleteValue: closeFileWatcherOf,
85475             onExistingValue: updateWildcardDirectoryWatcher
85476         });
85477         function createWildcardDirectoryWatcher(directory, flags) {
85478             return {
85479                 watcher: watchDirectory(directory, flags),
85480                 flags: flags
85481             };
85482         }
85483         function updateWildcardDirectoryWatcher(existingWatcher, flags, directory) {
85484             if (existingWatcher.flags === flags) {
85485                 return;
85486             }
85487             existingWatcher.watcher.close();
85488             existingWatchedForWildcards.set(directory, createWildcardDirectoryWatcher(directory, flags));
85489         }
85490     }
85491     ts.updateWatchingWildcardDirectories = updateWatchingWildcardDirectories;
85492     function isIgnoredFileFromWildCardWatching(_a) {
85493         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;
85494         var newPath = ts.removeIgnoredPath(fileOrDirectoryPath);
85495         if (!newPath) {
85496             writeLog("Project: " + configFileName + " Detected ignored path: " + fileOrDirectory);
85497             return true;
85498         }
85499         fileOrDirectoryPath = newPath;
85500         if (fileOrDirectoryPath === watchedDirPath)
85501             return false;
85502         if (ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, options, extraFileExtensions)) {
85503             writeLog("Project: " + configFileName + " Detected file add/remove of non supported extension: " + fileOrDirectory);
85504             return true;
85505         }
85506         if (ts.isExcludedFile(fileOrDirectory, configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), useCaseSensitiveFileNames, currentDirectory)) {
85507             writeLog("Project: " + configFileName + " Detected excluded file: " + fileOrDirectory);
85508             return true;
85509         }
85510         if (!program)
85511             return false;
85512         if (options.outFile || options.outDir)
85513             return false;
85514         if (ts.fileExtensionIs(fileOrDirectoryPath, ".d.ts")) {
85515             if (options.declarationDir)
85516                 return false;
85517         }
85518         else if (!ts.fileExtensionIsOneOf(fileOrDirectoryPath, ts.supportedJSExtensions)) {
85519             return false;
85520         }
85521         var filePathWithoutExtension = ts.removeFileExtension(fileOrDirectoryPath);
85522         var realProgram = isBuilderProgram(program) ? program.getProgramOrUndefined() : program;
85523         if (hasSourceFile((filePathWithoutExtension + ".ts")) ||
85524             hasSourceFile((filePathWithoutExtension + ".tsx"))) {
85525             writeLog("Project: " + configFileName + " Detected output file: " + fileOrDirectory);
85526             return true;
85527         }
85528         return false;
85529         function hasSourceFile(file) {
85530             return realProgram ?
85531                 !!realProgram.getSourceFileByPath(file) :
85532                 program.getState().fileInfos.has(file);
85533         }
85534     }
85535     ts.isIgnoredFileFromWildCardWatching = isIgnoredFileFromWildCardWatching;
85536     function isBuilderProgram(program) {
85537         return !!program.getState;
85538     }
85539     function isEmittedFileOfProgram(program, file) {
85540         if (!program) {
85541             return false;
85542         }
85543         return program.isEmittedFile(file);
85544     }
85545     ts.isEmittedFileOfProgram = isEmittedFileOfProgram;
85546     var WatchLogLevel;
85547     (function (WatchLogLevel) {
85548         WatchLogLevel[WatchLogLevel["None"] = 0] = "None";
85549         WatchLogLevel[WatchLogLevel["TriggerOnly"] = 1] = "TriggerOnly";
85550         WatchLogLevel[WatchLogLevel["Verbose"] = 2] = "Verbose";
85551     })(WatchLogLevel = ts.WatchLogLevel || (ts.WatchLogLevel = {}));
85552     function getWatchFactory(watchLogLevel, log, getDetailWatchInfo) {
85553         return getWatchFactoryWith(watchLogLevel, log, getDetailWatchInfo, watchFile, watchDirectory);
85554     }
85555     ts.getWatchFactory = getWatchFactory;
85556     function getWatchFactoryWith(watchLogLevel, log, getDetailWatchInfo, watchFile, watchDirectory) {
85557         var createFileWatcher = getCreateFileWatcher(watchLogLevel, watchFile);
85558         var createFilePathWatcher = watchLogLevel === WatchLogLevel.None ? watchFilePath : createFileWatcher;
85559         var createDirectoryWatcher = getCreateFileWatcher(watchLogLevel, watchDirectory);
85560         if (watchLogLevel === WatchLogLevel.Verbose && ts.sysLog === ts.noop) {
85561             ts.setSysLog(function (s) { return log(s); });
85562         }
85563         return {
85564             watchFile: function (host, file, callback, pollingInterval, options, detailInfo1, detailInfo2) {
85565                 return createFileWatcher(host, file, callback, pollingInterval, options, undefined, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo);
85566             },
85567             watchFilePath: function (host, file, callback, pollingInterval, options, path, detailInfo1, detailInfo2) {
85568                 return createFilePathWatcher(host, file, callback, pollingInterval, options, path, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo);
85569             },
85570             watchDirectory: function (host, directory, callback, flags, options, detailInfo1, detailInfo2) {
85571                 return createDirectoryWatcher(host, directory, callback, flags, options, undefined, detailInfo1, detailInfo2, watchDirectory, log, "DirectoryWatcher", getDetailWatchInfo);
85572             }
85573         };
85574     }
85575     function watchFile(host, file, callback, pollingInterval, options) {
85576         return host.watchFile(file, callback, pollingInterval, options);
85577     }
85578     function watchFilePath(host, file, callback, pollingInterval, options, path) {
85579         return watchFile(host, file, function (fileName, eventKind) { return callback(fileName, eventKind, path); }, pollingInterval, options);
85580     }
85581     function watchDirectory(host, directory, callback, flags, options) {
85582         return host.watchDirectory(directory, callback, (flags & 1) !== 0, options);
85583     }
85584     function getCreateFileWatcher(watchLogLevel, addWatch) {
85585         switch (watchLogLevel) {
85586             case WatchLogLevel.None:
85587                 return addWatch;
85588             case WatchLogLevel.TriggerOnly:
85589                 return createFileWatcherWithTriggerLogging;
85590             case WatchLogLevel.Verbose:
85591                 return addWatch === watchDirectory ? createDirectoryWatcherWithLogging : createFileWatcherWithLogging;
85592         }
85593     }
85594     function createFileWatcherWithLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo) {
85595         log(watchCaption + ":: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo));
85596         var watcher = createFileWatcherWithTriggerLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo);
85597         return {
85598             close: function () {
85599                 log(watchCaption + ":: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo));
85600                 watcher.close();
85601             }
85602         };
85603     }
85604     function createDirectoryWatcherWithLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo) {
85605         var watchInfo = watchCaption + ":: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo);
85606         log(watchInfo);
85607         var start = ts.timestamp();
85608         var watcher = createFileWatcherWithTriggerLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo);
85609         var elapsed = ts.timestamp() - start;
85610         log("Elapsed:: " + elapsed + "ms " + watchInfo);
85611         return {
85612             close: function () {
85613                 var watchInfo = watchCaption + ":: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo);
85614                 log(watchInfo);
85615                 var start = ts.timestamp();
85616                 watcher.close();
85617                 var elapsed = ts.timestamp() - start;
85618                 log("Elapsed:: " + elapsed + "ms " + watchInfo);
85619             }
85620         };
85621     }
85622     function createFileWatcherWithTriggerLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo) {
85623         return addWatch(host, file, function (fileName, cbOptional) {
85624             var triggerredInfo = watchCaption + ":: Triggered with " + fileName + " " + (cbOptional !== undefined ? cbOptional : "") + ":: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo);
85625             log(triggerredInfo);
85626             var start = ts.timestamp();
85627             cb(fileName, cbOptional, passThrough);
85628             var elapsed = ts.timestamp() - start;
85629             log("Elapsed:: " + elapsed + "ms " + triggerredInfo);
85630         }, flags, options);
85631     }
85632     function getFallbackOptions(options) {
85633         var fallbackPolling = options === null || options === void 0 ? void 0 : options.fallbackPolling;
85634         return {
85635             watchFile: fallbackPolling !== undefined ?
85636                 fallbackPolling :
85637                 ts.WatchFileKind.PriorityPollingInterval
85638         };
85639     }
85640     ts.getFallbackOptions = getFallbackOptions;
85641     function getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo) {
85642         return "WatchInfo: " + file + " " + flags + " " + JSON.stringify(options) + " " + (getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : detailInfo1 + " " + detailInfo2);
85643     }
85644     function closeFileWatcherOf(objWithWatcher) {
85645         objWithWatcher.watcher.close();
85646     }
85647     ts.closeFileWatcherOf = closeFileWatcherOf;
85648 })(ts || (ts = {}));
85649 var ts;
85650 (function (ts) {
85651     function findConfigFile(searchPath, fileExists, configName) {
85652         if (configName === void 0) { configName = "tsconfig.json"; }
85653         return ts.forEachAncestorDirectory(searchPath, function (ancestor) {
85654             var fileName = ts.combinePaths(ancestor, configName);
85655             return fileExists(fileName) ? fileName : undefined;
85656         });
85657     }
85658     ts.findConfigFile = findConfigFile;
85659     function resolveTripleslashReference(moduleName, containingFile) {
85660         var basePath = ts.getDirectoryPath(containingFile);
85661         var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName);
85662         return ts.normalizePath(referencedFileName);
85663     }
85664     ts.resolveTripleslashReference = resolveTripleslashReference;
85665     function computeCommonSourceDirectoryOfFilenames(fileNames, currentDirectory, getCanonicalFileName) {
85666         var commonPathComponents;
85667         var failed = ts.forEach(fileNames, function (sourceFile) {
85668             var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile, currentDirectory);
85669             sourcePathComponents.pop();
85670             if (!commonPathComponents) {
85671                 commonPathComponents = sourcePathComponents;
85672                 return;
85673             }
85674             var n = Math.min(commonPathComponents.length, sourcePathComponents.length);
85675             for (var i = 0; i < n; i++) {
85676                 if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) {
85677                     if (i === 0) {
85678                         return true;
85679                     }
85680                     commonPathComponents.length = i;
85681                     break;
85682                 }
85683             }
85684             if (sourcePathComponents.length < commonPathComponents.length) {
85685                 commonPathComponents.length = sourcePathComponents.length;
85686             }
85687         });
85688         if (failed) {
85689             return "";
85690         }
85691         if (!commonPathComponents) {
85692             return currentDirectory;
85693         }
85694         return ts.getPathFromPathComponents(commonPathComponents);
85695     }
85696     ts.computeCommonSourceDirectoryOfFilenames = computeCommonSourceDirectoryOfFilenames;
85697     function createCompilerHost(options, setParentNodes) {
85698         return createCompilerHostWorker(options, setParentNodes);
85699     }
85700     ts.createCompilerHost = createCompilerHost;
85701     function createCompilerHostWorker(options, setParentNodes, system) {
85702         if (system === void 0) { system = ts.sys; }
85703         var existingDirectories = new ts.Map();
85704         var getCanonicalFileName = ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames);
85705         var computeHash = ts.maybeBind(system, system.createHash) || ts.generateDjb2Hash;
85706         function getSourceFile(fileName, languageVersion, onError) {
85707             var text;
85708             try {
85709                 ts.performance.mark("beforeIORead");
85710                 text = compilerHost.readFile(fileName);
85711                 ts.performance.mark("afterIORead");
85712                 ts.performance.measure("I/O Read", "beforeIORead", "afterIORead");
85713             }
85714             catch (e) {
85715                 if (onError) {
85716                     onError(e.message);
85717                 }
85718                 text = "";
85719             }
85720             return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined;
85721         }
85722         function directoryExists(directoryPath) {
85723             if (existingDirectories.has(directoryPath)) {
85724                 return true;
85725             }
85726             if ((compilerHost.directoryExists || system.directoryExists)(directoryPath)) {
85727                 existingDirectories.set(directoryPath, true);
85728                 return true;
85729             }
85730             return false;
85731         }
85732         function writeFile(fileName, data, writeByteOrderMark, onError) {
85733             try {
85734                 ts.performance.mark("beforeIOWrite");
85735                 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); });
85736                 ts.performance.mark("afterIOWrite");
85737                 ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
85738             }
85739             catch (e) {
85740                 if (onError) {
85741                     onError(e.message);
85742                 }
85743             }
85744         }
85745         var outputFingerprints;
85746         function writeFileWorker(fileName, data, writeByteOrderMark) {
85747             if (!ts.isWatchSet(options) || !system.getModifiedTime) {
85748                 system.writeFile(fileName, data, writeByteOrderMark);
85749                 return;
85750             }
85751             if (!outputFingerprints) {
85752                 outputFingerprints = new ts.Map();
85753             }
85754             var hash = computeHash(data);
85755             var mtimeBefore = system.getModifiedTime(fileName);
85756             if (mtimeBefore) {
85757                 var fingerprint = outputFingerprints.get(fileName);
85758                 if (fingerprint &&
85759                     fingerprint.byteOrderMark === writeByteOrderMark &&
85760                     fingerprint.hash === hash &&
85761                     fingerprint.mtime.getTime() === mtimeBefore.getTime()) {
85762                     return;
85763                 }
85764             }
85765             system.writeFile(fileName, data, writeByteOrderMark);
85766             var mtimeAfter = system.getModifiedTime(fileName) || ts.missingFileModifiedTime;
85767             outputFingerprints.set(fileName, {
85768                 hash: hash,
85769                 byteOrderMark: writeByteOrderMark,
85770                 mtime: mtimeAfter
85771             });
85772         }
85773         function getDefaultLibLocation() {
85774             return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath()));
85775         }
85776         var newLine = ts.getNewLineCharacter(options, function () { return system.newLine; });
85777         var realpath = system.realpath && (function (path) { return system.realpath(path); });
85778         var compilerHost = {
85779             getSourceFile: getSourceFile,
85780             getDefaultLibLocation: getDefaultLibLocation,
85781             getDefaultLibFileName: function (options) { return ts.combinePaths(getDefaultLibLocation(), ts.getDefaultLibFileName(options)); },
85782             writeFile: writeFile,
85783             getCurrentDirectory: ts.memoize(function () { return system.getCurrentDirectory(); }),
85784             useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; },
85785             getCanonicalFileName: getCanonicalFileName,
85786             getNewLine: function () { return newLine; },
85787             fileExists: function (fileName) { return system.fileExists(fileName); },
85788             readFile: function (fileName) { return system.readFile(fileName); },
85789             trace: function (s) { return system.write(s + newLine); },
85790             directoryExists: function (directoryName) { return system.directoryExists(directoryName); },
85791             getEnvironmentVariable: function (name) { return system.getEnvironmentVariable ? system.getEnvironmentVariable(name) : ""; },
85792             getDirectories: function (path) { return system.getDirectories(path); },
85793             realpath: realpath,
85794             readDirectory: function (path, extensions, include, exclude, depth) { return system.readDirectory(path, extensions, include, exclude, depth); },
85795             createDirectory: function (d) { return system.createDirectory(d); },
85796             createHash: ts.maybeBind(system, system.createHash)
85797         };
85798         return compilerHost;
85799     }
85800     ts.createCompilerHostWorker = createCompilerHostWorker;
85801     function changeCompilerHostLikeToUseCache(host, toPath, getSourceFile) {
85802         var originalReadFile = host.readFile;
85803         var originalFileExists = host.fileExists;
85804         var originalDirectoryExists = host.directoryExists;
85805         var originalCreateDirectory = host.createDirectory;
85806         var originalWriteFile = host.writeFile;
85807         var readFileCache = new ts.Map();
85808         var fileExistsCache = new ts.Map();
85809         var directoryExistsCache = new ts.Map();
85810         var sourceFileCache = new ts.Map();
85811         var readFileWithCache = function (fileName) {
85812             var key = toPath(fileName);
85813             var value = readFileCache.get(key);
85814             if (value !== undefined)
85815                 return value !== false ? value : undefined;
85816             return setReadFileCache(key, fileName);
85817         };
85818         var setReadFileCache = function (key, fileName) {
85819             var newValue = originalReadFile.call(host, fileName);
85820             readFileCache.set(key, newValue !== undefined ? newValue : false);
85821             return newValue;
85822         };
85823         host.readFile = function (fileName) {
85824             var key = toPath(fileName);
85825             var value = readFileCache.get(key);
85826             if (value !== undefined)
85827                 return value !== false ? value : undefined;
85828             if (!ts.fileExtensionIs(fileName, ".json") && !ts.isBuildInfoFile(fileName)) {
85829                 return originalReadFile.call(host, fileName);
85830             }
85831             return setReadFileCache(key, fileName);
85832         };
85833         var getSourceFileWithCache = getSourceFile ? function (fileName, languageVersion, onError, shouldCreateNewSourceFile) {
85834             var key = toPath(fileName);
85835             var value = sourceFileCache.get(key);
85836             if (value)
85837                 return value;
85838             var sourceFile = getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile);
85839             if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json"))) {
85840                 sourceFileCache.set(key, sourceFile);
85841             }
85842             return sourceFile;
85843         } : undefined;
85844         host.fileExists = function (fileName) {
85845             var key = toPath(fileName);
85846             var value = fileExistsCache.get(key);
85847             if (value !== undefined)
85848                 return value;
85849             var newValue = originalFileExists.call(host, fileName);
85850             fileExistsCache.set(key, !!newValue);
85851             return newValue;
85852         };
85853         if (originalWriteFile) {
85854             host.writeFile = function (fileName, data, writeByteOrderMark, onError, sourceFiles) {
85855                 var key = toPath(fileName);
85856                 fileExistsCache.delete(key);
85857                 var value = readFileCache.get(key);
85858                 if (value !== undefined && value !== data) {
85859                     readFileCache.delete(key);
85860                     sourceFileCache.delete(key);
85861                 }
85862                 else if (getSourceFileWithCache) {
85863                     var sourceFile = sourceFileCache.get(key);
85864                     if (sourceFile && sourceFile.text !== data) {
85865                         sourceFileCache.delete(key);
85866                     }
85867                 }
85868                 originalWriteFile.call(host, fileName, data, writeByteOrderMark, onError, sourceFiles);
85869             };
85870         }
85871         if (originalDirectoryExists && originalCreateDirectory) {
85872             host.directoryExists = function (directory) {
85873                 var key = toPath(directory);
85874                 var value = directoryExistsCache.get(key);
85875                 if (value !== undefined)
85876                     return value;
85877                 var newValue = originalDirectoryExists.call(host, directory);
85878                 directoryExistsCache.set(key, !!newValue);
85879                 return newValue;
85880             };
85881             host.createDirectory = function (directory) {
85882                 var key = toPath(directory);
85883                 directoryExistsCache.delete(key);
85884                 originalCreateDirectory.call(host, directory);
85885             };
85886         }
85887         return {
85888             originalReadFile: originalReadFile,
85889             originalFileExists: originalFileExists,
85890             originalDirectoryExists: originalDirectoryExists,
85891             originalCreateDirectory: originalCreateDirectory,
85892             originalWriteFile: originalWriteFile,
85893             getSourceFileWithCache: getSourceFileWithCache,
85894             readFileWithCache: readFileWithCache
85895         };
85896     }
85897     ts.changeCompilerHostLikeToUseCache = changeCompilerHostLikeToUseCache;
85898     function getPreEmitDiagnostics(program, sourceFile, cancellationToken) {
85899         var diagnostics;
85900         diagnostics = ts.addRange(diagnostics, program.getConfigFileParsingDiagnostics());
85901         diagnostics = ts.addRange(diagnostics, program.getOptionsDiagnostics(cancellationToken));
85902         diagnostics = ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile, cancellationToken));
85903         diagnostics = ts.addRange(diagnostics, program.getGlobalDiagnostics(cancellationToken));
85904         diagnostics = ts.addRange(diagnostics, program.getSemanticDiagnostics(sourceFile, cancellationToken));
85905         if (ts.getEmitDeclarations(program.getCompilerOptions())) {
85906             diagnostics = ts.addRange(diagnostics, program.getDeclarationDiagnostics(sourceFile, cancellationToken));
85907         }
85908         return ts.sortAndDeduplicateDiagnostics(diagnostics || ts.emptyArray);
85909     }
85910     ts.getPreEmitDiagnostics = getPreEmitDiagnostics;
85911     function formatDiagnostics(diagnostics, host) {
85912         var output = "";
85913         for (var _i = 0, diagnostics_3 = diagnostics; _i < diagnostics_3.length; _i++) {
85914             var diagnostic = diagnostics_3[_i];
85915             output += formatDiagnostic(diagnostic, host);
85916         }
85917         return output;
85918     }
85919     ts.formatDiagnostics = formatDiagnostics;
85920     function formatDiagnostic(diagnostic, host) {
85921         var errorMessage = ts.diagnosticCategoryName(diagnostic) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine();
85922         if (diagnostic.file) {
85923             var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character;
85924             var fileName = diagnostic.file.fileName;
85925             var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); });
85926             return relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): " + errorMessage;
85927         }
85928         return errorMessage;
85929     }
85930     ts.formatDiagnostic = formatDiagnostic;
85931     var ForegroundColorEscapeSequences;
85932     (function (ForegroundColorEscapeSequences) {
85933         ForegroundColorEscapeSequences["Grey"] = "\u001B[90m";
85934         ForegroundColorEscapeSequences["Red"] = "\u001B[91m";
85935         ForegroundColorEscapeSequences["Yellow"] = "\u001B[93m";
85936         ForegroundColorEscapeSequences["Blue"] = "\u001B[94m";
85937         ForegroundColorEscapeSequences["Cyan"] = "\u001B[96m";
85938     })(ForegroundColorEscapeSequences = ts.ForegroundColorEscapeSequences || (ts.ForegroundColorEscapeSequences = {}));
85939     var gutterStyleSequence = "\u001b[7m";
85940     var gutterSeparator = " ";
85941     var resetEscapeSequence = "\u001b[0m";
85942     var ellipsis = "...";
85943     var halfIndent = "  ";
85944     var indent = "    ";
85945     function getCategoryFormat(category) {
85946         switch (category) {
85947             case ts.DiagnosticCategory.Error: return ForegroundColorEscapeSequences.Red;
85948             case ts.DiagnosticCategory.Warning: return ForegroundColorEscapeSequences.Yellow;
85949             case ts.DiagnosticCategory.Suggestion: return ts.Debug.fail("Should never get an Info diagnostic on the command line.");
85950             case ts.DiagnosticCategory.Message: return ForegroundColorEscapeSequences.Blue;
85951         }
85952     }
85953     function formatColorAndReset(text, formatStyle) {
85954         return formatStyle + text + resetEscapeSequence;
85955     }
85956     ts.formatColorAndReset = formatColorAndReset;
85957     function formatCodeSpan(file, start, length, indent, squiggleColor, host) {
85958         var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character;
85959         var _b = ts.getLineAndCharacterOfPosition(file, start + length), lastLine = _b.line, lastLineChar = _b.character;
85960         var lastLineInFile = ts.getLineAndCharacterOfPosition(file, file.text.length).line;
85961         var hasMoreThanFiveLines = (lastLine - firstLine) >= 4;
85962         var gutterWidth = (lastLine + 1 + "").length;
85963         if (hasMoreThanFiveLines) {
85964             gutterWidth = Math.max(ellipsis.length, gutterWidth);
85965         }
85966         var context = "";
85967         for (var i = firstLine; i <= lastLine; i++) {
85968             context += host.getNewLine();
85969             if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) {
85970                 context += indent + formatColorAndReset(ts.padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine();
85971                 i = lastLine - 1;
85972             }
85973             var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0);
85974             var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length;
85975             var lineContent = file.text.slice(lineStart, lineEnd);
85976             lineContent = lineContent.replace(/\s+$/g, "");
85977             lineContent = lineContent.replace("\t", " ");
85978             context += indent + formatColorAndReset(ts.padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator;
85979             context += lineContent + host.getNewLine();
85980             context += indent + formatColorAndReset(ts.padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator;
85981             context += squiggleColor;
85982             if (i === firstLine) {
85983                 var lastCharForLine = i === lastLine ? lastLineChar : undefined;
85984                 context += lineContent.slice(0, firstLineChar).replace(/\S/g, " ");
85985                 context += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "~");
85986             }
85987             else if (i === lastLine) {
85988                 context += lineContent.slice(0, lastLineChar).replace(/./g, "~");
85989             }
85990             else {
85991                 context += lineContent.replace(/./g, "~");
85992             }
85993             context += resetEscapeSequence;
85994         }
85995         return context;
85996     }
85997     function formatLocation(file, start, host, color) {
85998         if (color === void 0) { color = formatColorAndReset; }
85999         var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character;
86000         var relativeFileName = host ? ts.convertToRelativePath(file.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file.fileName;
86001         var output = "";
86002         output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan);
86003         output += ":";
86004         output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow);
86005         output += ":";
86006         output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow);
86007         return output;
86008     }
86009     ts.formatLocation = formatLocation;
86010     function formatDiagnosticsWithColorAndContext(diagnostics, host) {
86011         var output = "";
86012         for (var _i = 0, diagnostics_4 = diagnostics; _i < diagnostics_4.length; _i++) {
86013             var diagnostic = diagnostics_4[_i];
86014             if (diagnostic.file) {
86015                 var file = diagnostic.file, start = diagnostic.start;
86016                 output += formatLocation(file, start, host);
86017                 output += " - ";
86018             }
86019             output += formatColorAndReset(ts.diagnosticCategoryName(diagnostic), getCategoryFormat(diagnostic.category));
86020             output += formatColorAndReset(" TS" + diagnostic.code + ": ", ForegroundColorEscapeSequences.Grey);
86021             output += flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine());
86022             if (diagnostic.file) {
86023                 output += host.getNewLine();
86024                 output += formatCodeSpan(diagnostic.file, diagnostic.start, diagnostic.length, "", getCategoryFormat(diagnostic.category), host);
86025                 if (diagnostic.relatedInformation) {
86026                     output += host.getNewLine();
86027                     for (var _a = 0, _b = diagnostic.relatedInformation; _a < _b.length; _a++) {
86028                         var _c = _b[_a], file = _c.file, start = _c.start, length_8 = _c.length, messageText = _c.messageText;
86029                         if (file) {
86030                             output += host.getNewLine();
86031                             output += halfIndent + formatLocation(file, start, host);
86032                             output += formatCodeSpan(file, start, length_8, indent, ForegroundColorEscapeSequences.Cyan, host);
86033                         }
86034                         output += host.getNewLine();
86035                         output += indent + flattenDiagnosticMessageText(messageText, host.getNewLine());
86036                     }
86037                 }
86038             }
86039             output += host.getNewLine();
86040         }
86041         return output;
86042     }
86043     ts.formatDiagnosticsWithColorAndContext = formatDiagnosticsWithColorAndContext;
86044     function flattenDiagnosticMessageText(diag, newLine, indent) {
86045         if (indent === void 0) { indent = 0; }
86046         if (ts.isString(diag)) {
86047             return diag;
86048         }
86049         else if (diag === undefined) {
86050             return "";
86051         }
86052         var result = "";
86053         if (indent) {
86054             result += newLine;
86055             for (var i = 0; i < indent; i++) {
86056                 result += "  ";
86057             }
86058         }
86059         result += diag.messageText;
86060         indent++;
86061         if (diag.next) {
86062             for (var _i = 0, _a = diag.next; _i < _a.length; _i++) {
86063                 var kid = _a[_i];
86064                 result += flattenDiagnosticMessageText(kid, newLine, indent);
86065             }
86066         }
86067         return result;
86068     }
86069     ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText;
86070     function loadWithLocalCache(names, containingFile, redirectedReference, loader) {
86071         if (names.length === 0) {
86072             return [];
86073         }
86074         var resolutions = [];
86075         var cache = new ts.Map();
86076         for (var _i = 0, names_2 = names; _i < names_2.length; _i++) {
86077             var name = names_2[_i];
86078             var result = void 0;
86079             if (cache.has(name)) {
86080                 result = cache.get(name);
86081             }
86082             else {
86083                 cache.set(name, result = loader(name, containingFile, redirectedReference));
86084             }
86085             resolutions.push(result);
86086         }
86087         return resolutions;
86088     }
86089     ts.loadWithLocalCache = loadWithLocalCache;
86090     function forEachResolvedProjectReference(resolvedProjectReferences, cb) {
86091         return forEachProjectReference(undefined, resolvedProjectReferences, function (resolvedRef, parent) { return resolvedRef && cb(resolvedRef, parent); });
86092     }
86093     ts.forEachResolvedProjectReference = forEachResolvedProjectReference;
86094     function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) {
86095         var seenResolvedRefs;
86096         return worker(projectReferences, resolvedProjectReferences, undefined);
86097         function worker(projectReferences, resolvedProjectReferences, parent) {
86098             if (cbRef) {
86099                 var result = cbRef(projectReferences, parent);
86100                 if (result) {
86101                     return result;
86102                 }
86103             }
86104             return ts.forEach(resolvedProjectReferences, function (resolvedRef, index) {
86105                 if (resolvedRef && (seenResolvedRefs === null || seenResolvedRefs === void 0 ? void 0 : seenResolvedRefs.has(resolvedRef.sourceFile.path))) {
86106                     return undefined;
86107                 }
86108                 var result = cbResolvedRef(resolvedRef, parent, index);
86109                 if (result || !resolvedRef)
86110                     return result;
86111                 (seenResolvedRefs || (seenResolvedRefs = new ts.Set())).add(resolvedRef.sourceFile.path);
86112                 return worker(resolvedRef.commandLine.projectReferences, resolvedRef.references, resolvedRef);
86113             });
86114         }
86115     }
86116     ts.inferredTypesContainingFile = "__inferred type names__.ts";
86117     function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences) {
86118         if (!program || (hasChangedAutomaticTypeDirectiveNames === null || hasChangedAutomaticTypeDirectiveNames === void 0 ? void 0 : hasChangedAutomaticTypeDirectiveNames())) {
86119             return false;
86120         }
86121         if (!ts.arrayIsEqualTo(program.getRootFileNames(), rootFileNames)) {
86122             return false;
86123         }
86124         var seenResolvedRefs;
86125         if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) {
86126             return false;
86127         }
86128         if (program.getSourceFiles().some(sourceFileNotUptoDate)) {
86129             return false;
86130         }
86131         if (program.getMissingFilePaths().some(fileExists)) {
86132             return false;
86133         }
86134         var currentOptions = program.getCompilerOptions();
86135         if (!ts.compareDataObjects(currentOptions, newOptions)) {
86136             return false;
86137         }
86138         if (currentOptions.configFile && newOptions.configFile) {
86139             return currentOptions.configFile.text === newOptions.configFile.text;
86140         }
86141         return true;
86142         function sourceFileNotUptoDate(sourceFile) {
86143             return !sourceFileVersionUptoDate(sourceFile) ||
86144                 hasInvalidatedResolution(sourceFile.path);
86145         }
86146         function sourceFileVersionUptoDate(sourceFile) {
86147             return sourceFile.version === getSourceVersion(sourceFile.resolvedPath, sourceFile.fileName);
86148         }
86149         function projectReferenceUptoDate(oldRef, newRef, index) {
86150             if (!ts.projectReferenceIsEqualTo(oldRef, newRef)) {
86151                 return false;
86152             }
86153             return resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef);
86154         }
86155         function resolvedProjectReferenceUptoDate(oldResolvedRef, oldRef) {
86156             if (oldResolvedRef) {
86157                 if (ts.contains(seenResolvedRefs, oldResolvedRef)) {
86158                     return true;
86159                 }
86160                 if (!sourceFileVersionUptoDate(oldResolvedRef.sourceFile)) {
86161                     return false;
86162                 }
86163                 (seenResolvedRefs || (seenResolvedRefs = [])).push(oldResolvedRef);
86164                 return !ts.forEach(oldResolvedRef.references, function (childResolvedRef, index) {
86165                     return !resolvedProjectReferenceUptoDate(childResolvedRef, oldResolvedRef.commandLine.projectReferences[index]);
86166                 });
86167             }
86168             return !fileExists(resolveProjectReferencePath(oldRef));
86169         }
86170     }
86171     ts.isProgramUptoDate = isProgramUptoDate;
86172     function getConfigFileParsingDiagnostics(configFileParseResult) {
86173         return configFileParseResult.options.configFile ? __spreadArrays(configFileParseResult.options.configFile.parseDiagnostics, configFileParseResult.errors) :
86174             configFileParseResult.errors;
86175     }
86176     ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics;
86177     function shouldProgramCreateNewSourceFiles(program, newOptions) {
86178         if (!program)
86179             return false;
86180         var oldOptions = program.getCompilerOptions();
86181         return !!ts.sourceFileAffectingCompilerOptions.some(function (option) {
86182             return !ts.isJsonEqual(ts.getCompilerOptionValue(oldOptions, option), ts.getCompilerOptionValue(newOptions, option));
86183         });
86184     }
86185     function createCreateProgramOptions(rootNames, options, host, oldProgram, configFileParsingDiagnostics) {
86186         return {
86187             rootNames: rootNames,
86188             options: options,
86189             host: host,
86190             oldProgram: oldProgram,
86191             configFileParsingDiagnostics: configFileParsingDiagnostics
86192         };
86193     }
86194     function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
86195         var _a, _b;
86196         var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions;
86197         var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences;
86198         var oldProgram = createProgramOptions.oldProgram;
86199         var processingDefaultLibFiles;
86200         var processingOtherFiles;
86201         var files;
86202         var symlinks;
86203         var commonSourceDirectory;
86204         var diagnosticsProducingTypeChecker;
86205         var noDiagnosticsTypeChecker;
86206         var classifiableNames;
86207         var ambientModuleNameToUnmodifiedFileName = new ts.Map();
86208         var refFileMap;
86209         var cachedBindAndCheckDiagnosticsForFile = {};
86210         var cachedDeclarationDiagnosticsForFile = {};
86211         var resolvedTypeReferenceDirectives = new ts.Map();
86212         var fileProcessingDiagnostics = ts.createDiagnosticCollection();
86213         var maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
86214         var currentNodeModulesDepth = 0;
86215         var modulesWithElidedImports = new ts.Map();
86216         var sourceFilesFoundSearchingNodeModules = new ts.Map();
86217         var tracingData = ["program", "createProgram"];
86218         ts.tracing.begin.apply(ts.tracing, tracingData);
86219         ts.performance.mark("beforeProgram");
86220         var host = createProgramOptions.host || createCompilerHost(options);
86221         var configParsingHost = parseConfigHostFromCompilerHostLike(host);
86222         var skipDefaultLib = options.noLib;
86223         var getDefaultLibraryFileName = ts.memoize(function () { return host.getDefaultLibFileName(options); });
86224         var defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : ts.getDirectoryPath(getDefaultLibraryFileName());
86225         var programDiagnostics = ts.createDiagnosticCollection();
86226         var currentDirectory = host.getCurrentDirectory();
86227         var supportedExtensions = ts.getSupportedExtensions(options);
86228         var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
86229         var hasEmitBlockingDiagnostics = new ts.Map();
86230         var _compilerOptionsObjectLiteralSyntax;
86231         var moduleResolutionCache;
86232         var actualResolveModuleNamesWorker;
86233         var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
86234         if (host.resolveModuleNames) {
86235             actualResolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFile, reusedNames, redirectedReference, options).map(function (resolved) {
86236                 if (!resolved || resolved.extension !== undefined) {
86237                     return resolved;
86238                 }
86239                 var withExtension = ts.clone(resolved);
86240                 withExtension.extension = ts.extensionFromPath(resolved.resolvedFileName);
86241                 return withExtension;
86242             }); };
86243         }
86244         else {
86245             moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }, options);
86246             var loader_1 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache, redirectedReference).resolvedModule; };
86247             actualResolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_1); };
86248         }
86249         var actualResolveTypeReferenceDirectiveNamesWorker;
86250         if (host.resolveTypeReferenceDirectives) {
86251             actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); };
86252         }
86253         else {
86254             var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; };
86255             actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_2); };
86256         }
86257         var packageIdToSourceFile = new ts.Map();
86258         var sourceFileToPackageName = new ts.Map();
86259         var redirectTargetsMap = ts.createMultiMap();
86260         var filesByName = new ts.Map();
86261         var missingFilePaths;
86262         var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? new ts.Map() : undefined;
86263         var resolvedProjectReferences;
86264         var projectReferenceRedirects;
86265         var mapFromFileToProjectReferenceRedirects;
86266         var mapFromToProjectReferenceRedirectSource;
86267         var useSourceOfProjectReferenceRedirect = !!((_a = host.useSourceOfProjectReferenceRedirect) === null || _a === void 0 ? void 0 : _a.call(host)) &&
86268             !options.disableSourceOfProjectReferenceRedirect;
86269         var _c = updateHostForUseSourceOfProjectReferenceRedirect({
86270             compilerHost: host,
86271             getSymlinkCache: getSymlinkCache,
86272             useSourceOfProjectReferenceRedirect: useSourceOfProjectReferenceRedirect,
86273             toPath: toPath,
86274             getResolvedProjectReferences: getResolvedProjectReferences,
86275             getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect,
86276             forEachResolvedProjectReference: forEachResolvedProjectReference
86277         }), onProgramCreateComplete = _c.onProgramCreateComplete, fileExists = _c.fileExists, directoryExists = _c.directoryExists;
86278         ts.tracing.push("program", "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
86279         var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
86280         ts.tracing.pop();
86281         var structureIsReused;
86282         ts.tracing.push("program", "tryReuseStructureFromOldProgram", {});
86283         structureIsReused = tryReuseStructureFromOldProgram();
86284         ts.tracing.pop();
86285         if (structureIsReused !== 2) {
86286             processingDefaultLibFiles = [];
86287             processingOtherFiles = [];
86288             if (projectReferences) {
86289                 if (!resolvedProjectReferences) {
86290                     resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile);
86291                 }
86292                 if (rootNames.length) {
86293                     for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) {
86294                         var parsedRef = resolvedProjectReferences_1[_i];
86295                         if (!parsedRef)
86296                             continue;
86297                         var out = ts.outFile(parsedRef.commandLine.options);
86298                         if (useSourceOfProjectReferenceRedirect) {
86299                             if (out || ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) {
86300                                 for (var _d = 0, _e = parsedRef.commandLine.fileNames; _d < _e.length; _d++) {
86301                                     var fileName = _e[_d];
86302                                     processSourceFile(fileName, false, false, undefined);
86303                                 }
86304                             }
86305                         }
86306                         else {
86307                             if (out) {
86308                                 processSourceFile(ts.changeExtension(out, ".d.ts"), false, false, undefined);
86309                             }
86310                             else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) {
86311                                 for (var _f = 0, _g = parsedRef.commandLine.fileNames; _f < _g.length; _f++) {
86312                                     var fileName = _g[_f];
86313                                     if (!ts.fileExtensionIs(fileName, ".d.ts") && !ts.fileExtensionIs(fileName, ".json")) {
86314                                         processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), false, false, undefined);
86315                                     }
86316                                 }
86317                             }
86318                         }
86319                     }
86320                 }
86321             }
86322             ts.tracing.push("program", "processRootFiles", { count: rootNames.length });
86323             ts.forEach(rootNames, function (name) { return processRootFile(name, false, false); });
86324             ts.tracing.pop();
86325             var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray;
86326             if (typeReferences.length) {
86327                 ts.tracing.push("program", "processTypeReferences", { count: typeReferences.length });
86328                 var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
86329                 var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
86330                 var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
86331                 for (var i = 0; i < typeReferences.length; i++) {
86332                     processTypeReferenceDirective(typeReferences[i], resolutions[i]);
86333                 }
86334                 ts.tracing.pop();
86335             }
86336             if (rootNames.length && !skipDefaultLib) {
86337                 var defaultLibraryFileName = getDefaultLibraryFileName();
86338                 if (!options.lib && defaultLibraryFileName) {
86339                     processRootFile(defaultLibraryFileName, true, false);
86340                 }
86341                 else {
86342                     ts.forEach(options.lib, function (libFileName) {
86343                         processRootFile(ts.combinePaths(defaultLibraryPath, libFileName), true, false);
86344                     });
86345                 }
86346             }
86347             missingFilePaths = ts.arrayFrom(ts.mapDefinedIterator(filesByName.entries(), function (_a) {
86348                 var path = _a[0], file = _a[1];
86349                 return file === undefined ? path : undefined;
86350             }));
86351             files = ts.stableSort(processingDefaultLibFiles, compareDefaultLibFiles).concat(processingOtherFiles);
86352             processingDefaultLibFiles = undefined;
86353             processingOtherFiles = undefined;
86354         }
86355         ts.Debug.assert(!!missingFilePaths);
86356         if (oldProgram && host.onReleaseOldSourceFile) {
86357             var oldSourceFiles = oldProgram.getSourceFiles();
86358             for (var _h = 0, oldSourceFiles_1 = oldSourceFiles; _h < oldSourceFiles_1.length; _h++) {
86359                 var oldSourceFile = oldSourceFiles_1[_h];
86360                 var newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
86361                 if (shouldCreateNewSourceFile || !newFile ||
86362                     (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) {
86363                     host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
86364                 }
86365             }
86366             oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) {
86367                 if (!getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) {
86368                     host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), false);
86369                 }
86370             });
86371         }
86372         oldProgram = undefined;
86373         var program = {
86374             getRootFileNames: function () { return rootNames; },
86375             getSourceFile: getSourceFile,
86376             getSourceFileByPath: getSourceFileByPath,
86377             getSourceFiles: function () { return files; },
86378             getMissingFilePaths: function () { return missingFilePaths; },
86379             getRefFileMap: function () { return refFileMap; },
86380             getFilesByNameMap: function () { return filesByName; },
86381             getCompilerOptions: function () { return options; },
86382             getSyntacticDiagnostics: getSyntacticDiagnostics,
86383             getOptionsDiagnostics: getOptionsDiagnostics,
86384             getGlobalDiagnostics: getGlobalDiagnostics,
86385             getSemanticDiagnostics: getSemanticDiagnostics,
86386             getCachedSemanticDiagnostics: getCachedSemanticDiagnostics,
86387             getSuggestionDiagnostics: getSuggestionDiagnostics,
86388             getDeclarationDiagnostics: getDeclarationDiagnostics,
86389             getBindAndCheckDiagnostics: getBindAndCheckDiagnostics,
86390             getProgramDiagnostics: getProgramDiagnostics,
86391             getTypeChecker: getTypeChecker,
86392             getClassifiableNames: getClassifiableNames,
86393             getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker,
86394             getCommonSourceDirectory: getCommonSourceDirectory,
86395             emit: emit,
86396             getCurrentDirectory: function () { return currentDirectory; },
86397             getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); },
86398             getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); },
86399             getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); },
86400             getTypeCatalog: function () { return getDiagnosticsProducingTypeChecker().getTypeCatalog(); },
86401             getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); },
86402             getInstantiationCount: function () { return getDiagnosticsProducingTypeChecker().getInstantiationCount(); },
86403             getRelationCacheSizes: function () { return getDiagnosticsProducingTypeChecker().getRelationCacheSizes(); },
86404             getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; },
86405             getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; },
86406             isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
86407             isSourceFileDefaultLibrary: isSourceFileDefaultLibrary,
86408             dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker,
86409             getSourceFileFromReference: getSourceFileFromReference,
86410             getLibFileFromReference: getLibFileFromReference,
86411             sourceFileToPackageName: sourceFileToPackageName,
86412             redirectTargetsMap: redirectTargetsMap,
86413             isEmittedFile: isEmittedFile,
86414             getConfigFileParsingDiagnostics: getConfigFileParsingDiagnostics,
86415             getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
86416             getProjectReferences: getProjectReferences,
86417             getResolvedProjectReferences: getResolvedProjectReferences,
86418             getProjectReferenceRedirect: getProjectReferenceRedirect,
86419             getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect,
86420             getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath,
86421             forEachResolvedProjectReference: forEachResolvedProjectReference,
86422             isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
86423             emitBuildInfo: emitBuildInfo,
86424             fileExists: fileExists,
86425             directoryExists: directoryExists,
86426             getSymlinkCache: getSymlinkCache,
86427             realpath: (_b = host.realpath) === null || _b === void 0 ? void 0 : _b.bind(host),
86428             useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
86429             structureIsReused: structureIsReused,
86430         };
86431         onProgramCreateComplete();
86432         verifyCompilerOptions();
86433         ts.performance.mark("afterProgram");
86434         ts.performance.measure("Program", "beforeProgram", "afterProgram");
86435         ts.tracing.end.apply(ts.tracing, tracingData);
86436         return program;
86437         function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) {
86438             if (!moduleNames.length)
86439                 return ts.emptyArray;
86440             var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
86441             var redirectedReference = getRedirectReferenceForResolution(containingFile);
86442             ts.tracing.push("program", "resolveModuleNamesWorker", { containingFileName: containingFileName });
86443             ts.performance.mark("beforeResolveModule");
86444             var result = actualResolveModuleNamesWorker(moduleNames, containingFileName, reusedNames, redirectedReference);
86445             ts.performance.mark("afterResolveModule");
86446             ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
86447             ts.tracing.pop();
86448             return result;
86449         }
86450         function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) {
86451             if (!typeDirectiveNames.length)
86452                 return [];
86453             var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
86454             var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined;
86455             ts.tracing.push("program", "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName });
86456             ts.performance.mark("beforeResolveTypeReference");
86457             var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference);
86458             ts.performance.mark("afterResolveTypeReference");
86459             ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
86460             ts.tracing.pop();
86461             return result;
86462         }
86463         function getRedirectReferenceForResolution(file) {
86464             var redirect = getResolvedProjectReferenceToRedirect(file.originalFileName);
86465             if (redirect || !ts.fileExtensionIs(file.originalFileName, ".d.ts"))
86466                 return redirect;
86467             var resultFromDts = getRedirectReferenceForResolutionFromSourceOfProject(file.originalFileName, file.path);
86468             if (resultFromDts)
86469                 return resultFromDts;
86470             if (!host.realpath || !options.preserveSymlinks || !ts.stringContains(file.originalFileName, ts.nodeModulesPathPart))
86471                 return undefined;
86472             var realDeclarationFileName = host.realpath(file.originalFileName);
86473             var realDeclarationPath = toPath(realDeclarationFileName);
86474             return realDeclarationPath === file.path ? undefined : getRedirectReferenceForResolutionFromSourceOfProject(realDeclarationFileName, realDeclarationPath);
86475         }
86476         function getRedirectReferenceForResolutionFromSourceOfProject(fileName, filePath) {
86477             var source = getSourceOfProjectReferenceRedirect(fileName);
86478             if (ts.isString(source))
86479                 return getResolvedProjectReferenceToRedirect(source);
86480             if (!source)
86481                 return undefined;
86482             return forEachResolvedProjectReference(function (resolvedRef) {
86483                 var out = ts.outFile(resolvedRef.commandLine.options);
86484                 if (!out)
86485                     return undefined;
86486                 return toPath(out) === filePath ? resolvedRef : undefined;
86487             });
86488         }
86489         function compareDefaultLibFiles(a, b) {
86490             return ts.compareValues(getDefaultLibFilePriority(a), getDefaultLibFilePriority(b));
86491         }
86492         function getDefaultLibFilePriority(a) {
86493             if (ts.containsPath(defaultLibraryPath, a.fileName, false)) {
86494                 var basename = ts.getBaseFileName(a.fileName);
86495                 if (basename === "lib.d.ts" || basename === "lib.es6.d.ts")
86496                     return 0;
86497                 var name = ts.removeSuffix(ts.removePrefix(basename, "lib."), ".d.ts");
86498                 var index = ts.libs.indexOf(name);
86499                 if (index !== -1)
86500                     return index + 1;
86501             }
86502             return ts.libs.length + 2;
86503         }
86504         function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) {
86505             return moduleResolutionCache && ts.resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache);
86506         }
86507         function toPath(fileName) {
86508             return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
86509         }
86510         function getCommonSourceDirectory() {
86511             if (commonSourceDirectory === undefined) {
86512                 var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, program); });
86513                 if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) {
86514                     commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory);
86515                 }
86516                 else if (options.composite && options.configFilePath) {
86517                     commonSourceDirectory = ts.getDirectoryPath(ts.normalizeSlashes(options.configFilePath));
86518                     checkSourceFilesBelongToPath(emittedFiles, commonSourceDirectory);
86519                 }
86520                 else {
86521                     commonSourceDirectory = computeCommonSourceDirectory(emittedFiles);
86522                 }
86523                 if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) {
86524                     commonSourceDirectory += ts.directorySeparator;
86525                 }
86526             }
86527             return commonSourceDirectory;
86528         }
86529         function getClassifiableNames() {
86530             var _a;
86531             if (!classifiableNames) {
86532                 getTypeChecker();
86533                 classifiableNames = new ts.Set();
86534                 for (var _i = 0, files_2 = files; _i < files_2.length; _i++) {
86535                     var sourceFile = files_2[_i];
86536                     (_a = sourceFile.classifiableNames) === null || _a === void 0 ? void 0 : _a.forEach(function (value) { return classifiableNames.add(value); });
86537                 }
86538             }
86539             return classifiableNames;
86540         }
86541         function resolveModuleNamesReusingOldState(moduleNames, file) {
86542             if (structureIsReused === 0 && !file.ambientModuleNames.length) {
86543                 return resolveModuleNamesWorker(moduleNames, file, undefined);
86544             }
86545             var oldSourceFile = oldProgram && oldProgram.getSourceFile(file.fileName);
86546             if (oldSourceFile !== file && file.resolvedModules) {
86547                 var result_14 = [];
86548                 for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) {
86549                     var moduleName = moduleNames_1[_i];
86550                     var resolvedModule = file.resolvedModules.get(moduleName);
86551                     result_14.push(resolvedModule);
86552                 }
86553                 return result_14;
86554             }
86555             var unknownModuleNames;
86556             var result;
86557             var reusedNames;
86558             var predictedToResolveToAmbientModuleMarker = {};
86559             for (var i = 0; i < moduleNames.length; i++) {
86560                 var moduleName = moduleNames[i];
86561                 if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
86562                     var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName);
86563                     if (oldResolvedModule) {
86564                         if (ts.isTraceEnabled(options, host)) {
86565                             ts.trace(host, ts.Diagnostics.Reusing_resolution_of_module_0_to_file_1_from_old_program, moduleName, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory));
86566                         }
86567                         (result || (result = new Array(moduleNames.length)))[i] = oldResolvedModule;
86568                         (reusedNames || (reusedNames = [])).push(moduleName);
86569                         continue;
86570                     }
86571                 }
86572                 var resolvesToAmbientModuleInNonModifiedFile = false;
86573                 if (ts.contains(file.ambientModuleNames, moduleName)) {
86574                     resolvesToAmbientModuleInNonModifiedFile = true;
86575                     if (ts.isTraceEnabled(options, host)) {
86576                         ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1, moduleName, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory));
86577                     }
86578                 }
86579                 else {
86580                     resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName);
86581                 }
86582                 if (resolvesToAmbientModuleInNonModifiedFile) {
86583                     (result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
86584                 }
86585                 else {
86586                     (unknownModuleNames || (unknownModuleNames = [])).push(moduleName);
86587                 }
86588             }
86589             var resolutions = unknownModuleNames && unknownModuleNames.length
86590                 ? resolveModuleNamesWorker(unknownModuleNames, file, reusedNames)
86591                 : ts.emptyArray;
86592             if (!result) {
86593                 ts.Debug.assert(resolutions.length === moduleNames.length);
86594                 return resolutions;
86595             }
86596             var j = 0;
86597             for (var i = 0; i < result.length; i++) {
86598                 if (result[i]) {
86599                     if (result[i] === predictedToResolveToAmbientModuleMarker) {
86600                         result[i] = undefined;
86601                     }
86602                 }
86603                 else {
86604                     result[i] = resolutions[j];
86605                     j++;
86606                 }
86607             }
86608             ts.Debug.assert(j === resolutions.length);
86609             return result;
86610             function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName) {
86611                 var resolutionToFile = ts.getResolvedModule(oldSourceFile, moduleName);
86612                 var resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName);
86613                 if (resolutionToFile && resolvedFile) {
86614                     return false;
86615                 }
86616                 var unmodifiedFile = ambientModuleNameToUnmodifiedFileName.get(moduleName);
86617                 if (!unmodifiedFile) {
86618                     return false;
86619                 }
86620                 if (ts.isTraceEnabled(options, host)) {
86621                     ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, unmodifiedFile);
86622                 }
86623                 return true;
86624             }
86625         }
86626         function canReuseProjectReferences() {
86627             return !forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, parent, index) {
86628                 var newRef = (parent ? parent.commandLine.projectReferences : projectReferences)[index];
86629                 var newResolvedRef = parseProjectReferenceConfigFile(newRef);
86630                 if (oldResolvedRef) {
86631                     return !newResolvedRef || newResolvedRef.sourceFile !== oldResolvedRef.sourceFile;
86632                 }
86633                 else {
86634                     return newResolvedRef !== undefined;
86635                 }
86636             }, function (oldProjectReferences, parent) {
86637                 var newReferences = parent ? getResolvedProjectReferenceByPath(parent.sourceFile.path).commandLine.projectReferences : projectReferences;
86638                 return !ts.arrayIsEqualTo(oldProjectReferences, newReferences, ts.projectReferenceIsEqualTo);
86639             });
86640         }
86641         function tryReuseStructureFromOldProgram() {
86642             var _a;
86643             if (!oldProgram) {
86644                 return 0;
86645             }
86646             var oldOptions = oldProgram.getCompilerOptions();
86647             if (ts.changesAffectModuleResolution(oldOptions, options)) {
86648                 return 0;
86649             }
86650             var oldRootNames = oldProgram.getRootFileNames();
86651             if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) {
86652                 return 0;
86653             }
86654             if (!ts.arrayIsEqualTo(options.types, oldOptions.types)) {
86655                 return 0;
86656             }
86657             if (!canReuseProjectReferences()) {
86658                 return 0;
86659             }
86660             if (projectReferences) {
86661                 resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile);
86662             }
86663             var newSourceFiles = [];
86664             var modifiedSourceFiles = [];
86665             structureIsReused = 2;
86666             if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) {
86667                 return 0;
86668             }
86669             var oldSourceFiles = oldProgram.getSourceFiles();
86670             var seenPackageNames = new ts.Map();
86671             for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
86672                 var oldSourceFile = oldSourceFiles_2[_i];
86673                 var newSourceFile = host.getSourceFileByPath
86674                     ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, options.target, undefined, shouldCreateNewSourceFile)
86675                     : host.getSourceFile(oldSourceFile.fileName, options.target, undefined, shouldCreateNewSourceFile);
86676                 if (!newSourceFile) {
86677                     return 0;
86678                 }
86679                 ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`");
86680                 var fileChanged = void 0;
86681                 if (oldSourceFile.redirectInfo) {
86682                     if (newSourceFile !== oldSourceFile.redirectInfo.unredirected) {
86683                         return 0;
86684                     }
86685                     fileChanged = false;
86686                     newSourceFile = oldSourceFile;
86687                 }
86688                 else if (oldProgram.redirectTargetsMap.has(oldSourceFile.path)) {
86689                     if (newSourceFile !== oldSourceFile) {
86690                         return 0;
86691                     }
86692                     fileChanged = false;
86693                 }
86694                 else {
86695                     fileChanged = newSourceFile !== oldSourceFile;
86696                 }
86697                 newSourceFile.path = oldSourceFile.path;
86698                 newSourceFile.originalFileName = oldSourceFile.originalFileName;
86699                 newSourceFile.resolvedPath = oldSourceFile.resolvedPath;
86700                 newSourceFile.fileName = oldSourceFile.fileName;
86701                 var packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path);
86702                 if (packageName !== undefined) {
86703                     var prevKind = seenPackageNames.get(packageName);
86704                     var newKind = fileChanged ? 1 : 0;
86705                     if ((prevKind !== undefined && newKind === 1) || prevKind === 1) {
86706                         return 0;
86707                     }
86708                     seenPackageNames.set(packageName, newKind);
86709                 }
86710                 if (fileChanged) {
86711                     if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
86712                         return 0;
86713                     }
86714                     if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
86715                         structureIsReused = 1;
86716                     }
86717                     if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
86718                         structureIsReused = 1;
86719                     }
86720                     collectExternalModuleReferences(newSourceFile);
86721                     if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
86722                         structureIsReused = 1;
86723                     }
86724                     if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
86725                         structureIsReused = 1;
86726                     }
86727                     if ((oldSourceFile.flags & 3145728) !== (newSourceFile.flags & 3145728)) {
86728                         structureIsReused = 1;
86729                     }
86730                     if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
86731                         structureIsReused = 1;
86732                     }
86733                     modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
86734                 }
86735                 else if (hasInvalidatedResolution(oldSourceFile.path)) {
86736                     structureIsReused = 1;
86737                     modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
86738                 }
86739                 newSourceFiles.push(newSourceFile);
86740             }
86741             if (structureIsReused !== 2) {
86742                 return structureIsReused;
86743             }
86744             var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; });
86745             for (var _b = 0, oldSourceFiles_3 = oldSourceFiles; _b < oldSourceFiles_3.length; _b++) {
86746                 var oldFile = oldSourceFiles_3[_b];
86747                 if (!ts.contains(modifiedFiles, oldFile)) {
86748                     for (var _c = 0, _d = oldFile.ambientModuleNames; _c < _d.length; _c++) {
86749                         var moduleName = _d[_c];
86750                         ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName);
86751                     }
86752                 }
86753             }
86754             for (var _e = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _e < modifiedSourceFiles_1.length; _e++) {
86755                 var _f = modifiedSourceFiles_1[_e], oldSourceFile = _f.oldFile, newSourceFile = _f.newFile;
86756                 var moduleNames = getModuleNames(newSourceFile);
86757                 var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
86758                 var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo);
86759                 if (resolutionsChanged) {
86760                     structureIsReused = 1;
86761                     newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions);
86762                 }
86763                 else {
86764                     newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
86765                 }
86766                 var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
86767                 var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
86768                 var typeReferenceEesolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo);
86769                 if (typeReferenceEesolutionsChanged) {
86770                     structureIsReused = 1;
86771                     newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, typeReferenceResolutions);
86772                 }
86773                 else {
86774                     newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
86775                 }
86776             }
86777             if (structureIsReused !== 2) {
86778                 return structureIsReused;
86779             }
86780             if ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host)) {
86781                 return 1;
86782             }
86783             missingFilePaths = oldProgram.getMissingFilePaths();
86784             refFileMap = oldProgram.getRefFileMap();
86785             ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
86786             for (var _g = 0, newSourceFiles_1 = newSourceFiles; _g < newSourceFiles_1.length; _g++) {
86787                 var newSourceFile = newSourceFiles_1[_g];
86788                 filesByName.set(newSourceFile.path, newSourceFile);
86789             }
86790             var oldFilesByNameMap = oldProgram.getFilesByNameMap();
86791             oldFilesByNameMap.forEach(function (oldFile, path) {
86792                 if (!oldFile) {
86793                     filesByName.set(path, oldFile);
86794                     return;
86795                 }
86796                 if (oldFile.path === path) {
86797                     if (oldProgram.isSourceFileFromExternalLibrary(oldFile)) {
86798                         sourceFilesFoundSearchingNodeModules.set(oldFile.path, true);
86799                     }
86800                     return;
86801                 }
86802                 filesByName.set(path, filesByName.get(oldFile.path));
86803             });
86804             files = newSourceFiles;
86805             fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
86806             for (var _h = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _h < modifiedSourceFiles_2.length; _h++) {
86807                 var modifiedFile = modifiedSourceFiles_2[_h];
86808                 fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile);
86809             }
86810             resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives();
86811             sourceFileToPackageName = oldProgram.sourceFileToPackageName;
86812             redirectTargetsMap = oldProgram.redirectTargetsMap;
86813             return 2;
86814         }
86815         function getEmitHost(writeFileCallback) {
86816             return {
86817                 getPrependNodes: getPrependNodes,
86818                 getCanonicalFileName: getCanonicalFileName,
86819                 getCommonSourceDirectory: program.getCommonSourceDirectory,
86820                 getCompilerOptions: program.getCompilerOptions,
86821                 getCurrentDirectory: function () { return currentDirectory; },
86822                 getNewLine: function () { return host.getNewLine(); },
86823                 getSourceFile: program.getSourceFile,
86824                 getSourceFileByPath: program.getSourceFileByPath,
86825                 getSourceFiles: program.getSourceFiles,
86826                 getLibFileFromReference: program.getLibFileFromReference,
86827                 isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
86828                 getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect,
86829                 getProjectReferenceRedirect: getProjectReferenceRedirect,
86830                 isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
86831                 getSymlinkCache: getSymlinkCache,
86832                 writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }),
86833                 isEmitBlocked: isEmitBlocked,
86834                 readFile: function (f) { return host.readFile(f); },
86835                 fileExists: function (f) {
86836                     var path = toPath(f);
86837                     if (getSourceFileByPath(path))
86838                         return true;
86839                     if (ts.contains(missingFilePaths, path))
86840                         return false;
86841                     return host.fileExists(f);
86842                 },
86843                 useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
86844                 getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); },
86845                 getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); },
86846                 redirectTargetsMap: redirectTargetsMap,
86847             };
86848         }
86849         function emitBuildInfo(writeFileCallback) {
86850             ts.Debug.assert(!ts.outFile(options));
86851             var tracingData = ["emit", "emitBuildInfo"];
86852             ts.tracing.begin.apply(ts.tracing, tracingData);
86853             ts.performance.mark("beforeEmit");
86854             var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), undefined, ts.noTransformers, false, true);
86855             ts.performance.mark("afterEmit");
86856             ts.performance.measure("Emit", "beforeEmit", "afterEmit");
86857             ts.tracing.end.apply(ts.tracing, tracingData);
86858             return emitResult;
86859         }
86860         function getResolvedProjectReferences() {
86861             return resolvedProjectReferences;
86862         }
86863         function getProjectReferences() {
86864             return projectReferences;
86865         }
86866         function getPrependNodes() {
86867             return createPrependNodes(projectReferences, function (_ref, index) { var _a; return (_a = resolvedProjectReferences[index]) === null || _a === void 0 ? void 0 : _a.commandLine; }, function (fileName) {
86868                 var path = toPath(fileName);
86869                 var sourceFile = getSourceFileByPath(path);
86870                 return sourceFile ? sourceFile.text : filesByName.has(path) ? undefined : host.readFile(path);
86871             });
86872         }
86873         function isSourceFileFromExternalLibrary(file) {
86874             return !!sourceFilesFoundSearchingNodeModules.get(file.path);
86875         }
86876         function isSourceFileDefaultLibrary(file) {
86877             if (file.hasNoDefaultLib) {
86878                 return true;
86879             }
86880             if (!options.noLib) {
86881                 return false;
86882             }
86883             var equalityComparer = host.useCaseSensitiveFileNames() ? ts.equateStringsCaseSensitive : ts.equateStringsCaseInsensitive;
86884             if (!options.lib) {
86885                 return equalityComparer(file.fileName, getDefaultLibraryFileName());
86886             }
86887             else {
86888                 return ts.some(options.lib, function (libFileName) { return equalityComparer(file.fileName, ts.combinePaths(defaultLibraryPath, libFileName)); });
86889             }
86890         }
86891         function getDiagnosticsProducingTypeChecker() {
86892             return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true));
86893         }
86894         function dropDiagnosticsProducingTypeChecker() {
86895             diagnosticsProducingTypeChecker = undefined;
86896         }
86897         function getTypeChecker() {
86898             return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false));
86899         }
86900         function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) {
86901             var tracingData = ["emit", "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }];
86902             ts.tracing.begin.apply(ts.tracing, tracingData);
86903             var result = runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); });
86904             ts.tracing.end.apply(ts.tracing, tracingData);
86905             return result;
86906         }
86907         function isEmitBlocked(emitFileName) {
86908             return hasEmitBlockingDiagnostics.has(toPath(emitFileName));
86909         }
86910         function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit) {
86911             if (!forceDtsEmit) {
86912                 var result = handleNoEmitOptions(program, sourceFile, writeFileCallback, cancellationToken);
86913                 if (result)
86914                     return result;
86915             }
86916             var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(ts.outFile(options) ? undefined : sourceFile, cancellationToken);
86917             ts.performance.mark("beforeEmit");
86918             var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, false, forceDtsEmit);
86919             ts.performance.mark("afterEmit");
86920             ts.performance.measure("Emit", "beforeEmit", "afterEmit");
86921             return emitResult;
86922         }
86923         function getSourceFile(fileName) {
86924             return getSourceFileByPath(toPath(fileName));
86925         }
86926         function getSourceFileByPath(path) {
86927             return filesByName.get(path) || undefined;
86928         }
86929         function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) {
86930             if (sourceFile) {
86931                 return getDiagnostics(sourceFile, cancellationToken);
86932             }
86933             return ts.sortAndDeduplicateDiagnostics(ts.flatMap(program.getSourceFiles(), function (sourceFile) {
86934                 if (cancellationToken) {
86935                     cancellationToken.throwIfCancellationRequested();
86936                 }
86937                 return getDiagnostics(sourceFile, cancellationToken);
86938             }));
86939         }
86940         function getSyntacticDiagnostics(sourceFile, cancellationToken) {
86941             return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken);
86942         }
86943         function getSemanticDiagnostics(sourceFile, cancellationToken) {
86944             return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken);
86945         }
86946         function getCachedSemanticDiagnostics(sourceFile) {
86947             var _a;
86948             return sourceFile
86949                 ? (_a = cachedBindAndCheckDiagnosticsForFile.perFile) === null || _a === void 0 ? void 0 : _a.get(sourceFile.path) : cachedBindAndCheckDiagnosticsForFile.allDiagnostics;
86950         }
86951         function getBindAndCheckDiagnostics(sourceFile, cancellationToken) {
86952             return getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken);
86953         }
86954         function getProgramDiagnostics(sourceFile) {
86955             if (ts.skipTypeChecking(sourceFile, options, program)) {
86956                 return ts.emptyArray;
86957             }
86958             var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName);
86959             var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName);
86960             return getMergedProgramDiagnostics(sourceFile, fileProcessingDiagnosticsInFile, programDiagnosticsInFile);
86961         }
86962         function getMergedProgramDiagnostics(sourceFile) {
86963             var _a;
86964             var allDiagnostics = [];
86965             for (var _i = 1; _i < arguments.length; _i++) {
86966                 allDiagnostics[_i - 1] = arguments[_i];
86967             }
86968             var flatDiagnostics = ts.flatten(allDiagnostics);
86969             if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) {
86970                 return flatDiagnostics;
86971             }
86972             return getDiagnosticsWithPrecedingDirectives(sourceFile, sourceFile.commentDirectives, flatDiagnostics).diagnostics;
86973         }
86974         function getDeclarationDiagnostics(sourceFile, cancellationToken) {
86975             var options = program.getCompilerOptions();
86976             if (!sourceFile || ts.outFile(options)) {
86977                 return getDeclarationDiagnosticsWorker(sourceFile, cancellationToken);
86978             }
86979             else {
86980                 return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken);
86981             }
86982         }
86983         function getSyntacticDiagnosticsForFile(sourceFile) {
86984             if (ts.isSourceFileJS(sourceFile)) {
86985                 if (!sourceFile.additionalSyntacticDiagnostics) {
86986                     sourceFile.additionalSyntacticDiagnostics = getJSSyntacticDiagnosticsForFile(sourceFile);
86987                 }
86988                 return ts.concatenate(sourceFile.additionalSyntacticDiagnostics, sourceFile.parseDiagnostics);
86989             }
86990             return sourceFile.parseDiagnostics;
86991         }
86992         function runWithCancellationToken(func) {
86993             try {
86994                 return func();
86995             }
86996             catch (e) {
86997                 if (e instanceof ts.OperationCanceledException) {
86998                     noDiagnosticsTypeChecker = undefined;
86999                     diagnosticsProducingTypeChecker = undefined;
87000                 }
87001                 throw e;
87002             }
87003         }
87004         function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) {
87005             return ts.concatenate(filterSemanticDiagnotics(getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken), options), getProgramDiagnostics(sourceFile));
87006         }
87007         function getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken) {
87008             return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedBindAndCheckDiagnosticsForFile, getBindAndCheckDiagnosticsForFileNoCache);
87009         }
87010         function getBindAndCheckDiagnosticsForFileNoCache(sourceFile, cancellationToken) {
87011             return runWithCancellationToken(function () {
87012                 if (ts.skipTypeChecking(sourceFile, options, program)) {
87013                     return ts.emptyArray;
87014                 }
87015                 var typeChecker = getDiagnosticsProducingTypeChecker();
87016                 ts.Debug.assert(!!sourceFile.bindDiagnostics);
87017                 var isCheckJs = ts.isCheckJsEnabledForFile(sourceFile, options);
87018                 var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
87019                 var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 || sourceFile.scriptKind === 4 ||
87020                     sourceFile.scriptKind === 5 || isCheckJs || sourceFile.scriptKind === 7);
87021                 var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray;
87022                 var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray;
87023                 return getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined);
87024             });
87025         }
87026         function getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics) {
87027             var _a;
87028             var allDiagnostics = [];
87029             for (var _i = 2; _i < arguments.length; _i++) {
87030                 allDiagnostics[_i - 2] = arguments[_i];
87031             }
87032             var flatDiagnostics = ts.flatten(allDiagnostics);
87033             if (!includeBindAndCheckDiagnostics || !((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) {
87034                 return flatDiagnostics;
87035             }
87036             var _b = getDiagnosticsWithPrecedingDirectives(sourceFile, sourceFile.commentDirectives, flatDiagnostics), diagnostics = _b.diagnostics, directives = _b.directives;
87037             for (var _c = 0, _d = directives.getUnusedExpectations(); _c < _d.length; _c++) {
87038                 var errorExpectation = _d[_c];
87039                 diagnostics.push(ts.createDiagnosticForRange(sourceFile, errorExpectation.range, ts.Diagnostics.Unused_ts_expect_error_directive));
87040             }
87041             return diagnostics;
87042         }
87043         function getDiagnosticsWithPrecedingDirectives(sourceFile, commentDirectives, flatDiagnostics) {
87044             var directives = ts.createCommentDirectivesMap(sourceFile, commentDirectives);
87045             var diagnostics = flatDiagnostics.filter(function (diagnostic) { return markPrecedingCommentDirectiveLine(diagnostic, directives) === -1; });
87046             return { diagnostics: diagnostics, directives: directives };
87047         }
87048         function getSuggestionDiagnostics(sourceFile, cancellationToken) {
87049             return runWithCancellationToken(function () {
87050                 return getDiagnosticsProducingTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken);
87051             });
87052         }
87053         function markPrecedingCommentDirectiveLine(diagnostic, directives) {
87054             var file = diagnostic.file, start = diagnostic.start;
87055             if (!file) {
87056                 return -1;
87057             }
87058             var lineStarts = ts.getLineStarts(file);
87059             var line = ts.computeLineAndCharacterOfPosition(lineStarts, start).line - 1;
87060             while (line >= 0) {
87061                 if (directives.markUsed(line)) {
87062                     return line;
87063                 }
87064                 var lineText = file.text.slice(lineStarts[line], lineStarts[line + 1]).trim();
87065                 if (lineText !== "" && !/^(\s*)\/\/(.*)$/.test(lineText)) {
87066                     return -1;
87067                 }
87068                 line--;
87069             }
87070             return -1;
87071         }
87072         function getJSSyntacticDiagnosticsForFile(sourceFile) {
87073             return runWithCancellationToken(function () {
87074                 var diagnostics = [];
87075                 walk(sourceFile, sourceFile);
87076                 ts.forEachChildRecursively(sourceFile, walk, walkArray);
87077                 return diagnostics;
87078                 function walk(node, parent) {
87079                     switch (parent.kind) {
87080                         case 160:
87081                         case 163:
87082                         case 165:
87083                             if (parent.questionToken === node) {
87084                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?"));
87085                                 return "skip";
87086                             }
87087                         case 164:
87088                         case 166:
87089                         case 167:
87090                         case 168:
87091                         case 208:
87092                         case 251:
87093                         case 209:
87094                         case 249:
87095                             if (parent.type === node) {
87096                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files));
87097                                 return "skip";
87098                             }
87099                     }
87100                     switch (node.kind) {
87101                         case 262:
87102                             if (node.isTypeOnly) {
87103                                 diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "import type"));
87104                                 return "skip";
87105                             }
87106                             break;
87107                         case 267:
87108                             if (node.isTypeOnly) {
87109                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "export type"));
87110                                 return "skip";
87111                             }
87112                             break;
87113                         case 260:
87114                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files));
87115                             return "skip";
87116                         case 266:
87117                             if (node.isExportEquals) {
87118                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files));
87119                                 return "skip";
87120                             }
87121                             break;
87122                         case 286:
87123                             var heritageClause = node;
87124                             if (heritageClause.token === 116) {
87125                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files));
87126                                 return "skip";
87127                             }
87128                             break;
87129                         case 253:
87130                             var interfaceKeyword = ts.tokenToString(117);
87131                             ts.Debug.assertIsDefined(interfaceKeyword);
87132                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword));
87133                             return "skip";
87134                         case 256:
87135                             var moduleKeyword = node.flags & 16 ? ts.tokenToString(140) : ts.tokenToString(139);
87136                             ts.Debug.assertIsDefined(moduleKeyword);
87137                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword));
87138                             return "skip";
87139                         case 254:
87140                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files));
87141                             return "skip";
87142                         case 255:
87143                             var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(91));
87144                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword));
87145                             return "skip";
87146                         case 225:
87147                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files));
87148                             return "skip";
87149                         case 224:
87150                             diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files));
87151                             return "skip";
87152                         case 206:
87153                             ts.Debug.fail();
87154                     }
87155                 }
87156                 function walkArray(nodes, parent) {
87157                     if (parent.decorators === nodes && !options.experimentalDecorators) {
87158                         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));
87159                     }
87160                     switch (parent.kind) {
87161                         case 252:
87162                         case 221:
87163                         case 165:
87164                         case 166:
87165                         case 167:
87166                         case 168:
87167                         case 208:
87168                         case 251:
87169                         case 209:
87170                             if (nodes === parent.typeParameters) {
87171                                 diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files));
87172                                 return "skip";
87173                             }
87174                         case 232:
87175                             if (nodes === parent.modifiers) {
87176                                 checkModifiers(parent.modifiers, parent.kind === 232);
87177                                 return "skip";
87178                             }
87179                             break;
87180                         case 163:
87181                             if (nodes === parent.modifiers) {
87182                                 for (var _i = 0, _a = nodes; _i < _a.length; _i++) {
87183                                     var modifier = _a[_i];
87184                                     if (modifier.kind !== 123) {
87185                                         diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind)));
87186                                     }
87187                                 }
87188                                 return "skip";
87189                             }
87190                             break;
87191                         case 160:
87192                             if (nodes === parent.modifiers) {
87193                                 diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files));
87194                                 return "skip";
87195                             }
87196                             break;
87197                         case 203:
87198                         case 204:
87199                         case 223:
87200                         case 274:
87201                         case 275:
87202                         case 205:
87203                             if (nodes === parent.typeArguments) {
87204                                 diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files));
87205                                 return "skip";
87206                             }
87207                             break;
87208                     }
87209                 }
87210                 function checkModifiers(modifiers, isConstValid) {
87211                     for (var _i = 0, modifiers_2 = modifiers; _i < modifiers_2.length; _i++) {
87212                         var modifier = modifiers_2[_i];
87213                         switch (modifier.kind) {
87214                             case 84:
87215                                 if (isConstValid) {
87216                                     continue;
87217                                 }
87218                             case 122:
87219                             case 120:
87220                             case 121:
87221                             case 142:
87222                             case 133:
87223                             case 125:
87224                                 diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind)));
87225                                 break;
87226                             case 123:
87227                             case 92:
87228                             case 87:
87229                         }
87230                     }
87231                 }
87232                 function createDiagnosticForNodeArray(nodes, message, arg0, arg1, arg2) {
87233                     var start = nodes.pos;
87234                     return ts.createFileDiagnostic(sourceFile, start, nodes.end - start, message, arg0, arg1, arg2);
87235                 }
87236                 function createDiagnosticForNode(node, message, arg0, arg1, arg2) {
87237                     return ts.createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2);
87238                 }
87239             });
87240         }
87241         function getDeclarationDiagnosticsWorker(sourceFile, cancellationToken) {
87242             return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedDeclarationDiagnosticsForFile, getDeclarationDiagnosticsForFileNoCache);
87243         }
87244         function getDeclarationDiagnosticsForFileNoCache(sourceFile, cancellationToken) {
87245             return runWithCancellationToken(function () {
87246                 var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken);
87247                 return ts.getDeclarationDiagnostics(getEmitHost(ts.noop), resolver, sourceFile) || ts.emptyArray;
87248             });
87249         }
87250         function getAndCacheDiagnostics(sourceFile, cancellationToken, cache, getDiagnostics) {
87251             var _a;
87252             var cachedResult = sourceFile
87253                 ? (_a = cache.perFile) === null || _a === void 0 ? void 0 : _a.get(sourceFile.path) : cache.allDiagnostics;
87254             if (cachedResult) {
87255                 return cachedResult;
87256             }
87257             var result = getDiagnostics(sourceFile, cancellationToken);
87258             if (sourceFile) {
87259                 (cache.perFile || (cache.perFile = new ts.Map())).set(sourceFile.path, result);
87260             }
87261             else {
87262                 cache.allDiagnostics = result;
87263             }
87264             return result;
87265         }
87266         function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) {
87267             return sourceFile.isDeclarationFile ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken);
87268         }
87269         function getOptionsDiagnostics() {
87270             return ts.sortAndDeduplicateDiagnostics(ts.concatenate(fileProcessingDiagnostics.getGlobalDiagnostics(), ts.concatenate(programDiagnostics.getGlobalDiagnostics(), getOptionsDiagnosticsOfConfigFile())));
87271         }
87272         function getOptionsDiagnosticsOfConfigFile() {
87273             if (!options.configFile) {
87274                 return ts.emptyArray;
87275             }
87276             var diagnostics = programDiagnostics.getDiagnostics(options.configFile.fileName);
87277             forEachResolvedProjectReference(function (resolvedRef) {
87278                 diagnostics = ts.concatenate(diagnostics, programDiagnostics.getDiagnostics(resolvedRef.sourceFile.fileName));
87279             });
87280             return diagnostics;
87281         }
87282         function getGlobalDiagnostics() {
87283             return rootNames.length ? ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()) : ts.emptyArray;
87284         }
87285         function getConfigFileParsingDiagnostics() {
87286             return configFileParsingDiagnostics || ts.emptyArray;
87287         }
87288         function processRootFile(fileName, isDefaultLib, ignoreNoDefaultLib) {
87289             processSourceFile(ts.normalizePath(fileName), isDefaultLib, ignoreNoDefaultLib, undefined);
87290         }
87291         function fileReferenceIsEqualTo(a, b) {
87292             return a.fileName === b.fileName;
87293         }
87294         function moduleNameIsEqualTo(a, b) {
87295             return a.kind === 78
87296                 ? b.kind === 78 && a.escapedText === b.escapedText
87297                 : b.kind === 10 && a.text === b.text;
87298         }
87299         function createSyntheticImport(text, file) {
87300             var externalHelpersModuleReference = ts.factory.createStringLiteral(text);
87301             var importDecl = ts.factory.createImportDeclaration(undefined, undefined, undefined, externalHelpersModuleReference);
87302             ts.addEmitFlags(importDecl, 67108864);
87303             ts.setParent(externalHelpersModuleReference, importDecl);
87304             ts.setParent(importDecl, file);
87305             externalHelpersModuleReference.flags &= ~8;
87306             importDecl.flags &= ~8;
87307             return externalHelpersModuleReference;
87308         }
87309         function collectExternalModuleReferences(file) {
87310             if (file.imports) {
87311                 return;
87312             }
87313             var isJavaScriptFile = ts.isSourceFileJS(file);
87314             var isExternalModuleFile = ts.isExternalModule(file);
87315             var imports;
87316             var moduleAugmentations;
87317             var ambientModules;
87318             if ((options.isolatedModules || isExternalModuleFile)
87319                 && !file.isDeclarationFile) {
87320                 if (options.importHelpers) {
87321                     imports = [createSyntheticImport(ts.externalHelpersModuleNameText, file)];
87322                 }
87323                 var jsxImport = ts.getJSXRuntimeImport(ts.getJSXImplicitImportBase(options, file), options);
87324                 if (jsxImport) {
87325                     (imports || (imports = [])).push(createSyntheticImport(jsxImport, file));
87326                 }
87327             }
87328             for (var _i = 0, _a = file.statements; _i < _a.length; _i++) {
87329                 var node = _a[_i];
87330                 collectModuleReferences(node, false);
87331             }
87332             if ((file.flags & 1048576) || isJavaScriptFile) {
87333                 collectDynamicImportOrRequireCalls(file);
87334             }
87335             file.imports = imports || ts.emptyArray;
87336             file.moduleAugmentations = moduleAugmentations || ts.emptyArray;
87337             file.ambientModuleNames = ambientModules || ts.emptyArray;
87338             return;
87339             function collectModuleReferences(node, inAmbientModule) {
87340                 if (ts.isAnyImportOrReExport(node)) {
87341                     var moduleNameExpr = ts.getExternalModuleName(node);
87342                     if (moduleNameExpr && ts.isStringLiteral(moduleNameExpr) && moduleNameExpr.text && (!inAmbientModule || !ts.isExternalModuleNameRelative(moduleNameExpr.text))) {
87343                         imports = ts.append(imports, moduleNameExpr);
87344                     }
87345                 }
87346                 else if (ts.isModuleDeclaration(node)) {
87347                     if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2) || file.isDeclarationFile)) {
87348                         var nameText = ts.getTextOfIdentifierOrLiteral(node.name);
87349                         if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(nameText))) {
87350                             (moduleAugmentations || (moduleAugmentations = [])).push(node.name);
87351                         }
87352                         else if (!inAmbientModule) {
87353                             if (file.isDeclarationFile) {
87354                                 (ambientModules || (ambientModules = [])).push(nameText);
87355                             }
87356                             var body = node.body;
87357                             if (body) {
87358                                 for (var _i = 0, _a = body.statements; _i < _a.length; _i++) {
87359                                     var statement = _a[_i];
87360                                     collectModuleReferences(statement, true);
87361                                 }
87362                             }
87363                         }
87364                     }
87365                 }
87366             }
87367             function collectDynamicImportOrRequireCalls(file) {
87368                 var r = /import|require/g;
87369                 while (r.exec(file.text) !== null) {
87370                     var node = getNodeAtPosition(file, r.lastIndex);
87371                     if (isJavaScriptFile && ts.isRequireCall(node, true)) {
87372                         imports = ts.append(imports, node.arguments[0]);
87373                     }
87374                     else if (ts.isImportCall(node) && node.arguments.length === 1 && ts.isStringLiteralLike(node.arguments[0])) {
87375                         imports = ts.append(imports, node.arguments[0]);
87376                     }
87377                     else if (ts.isLiteralImportTypeNode(node)) {
87378                         imports = ts.append(imports, node.argument.literal);
87379                     }
87380                 }
87381             }
87382             function getNodeAtPosition(sourceFile, position) {
87383                 var current = sourceFile;
87384                 var getContainingChild = function (child) {
87385                     if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1)))) {
87386                         return child;
87387                     }
87388                 };
87389                 while (true) {
87390                     var child = isJavaScriptFile && ts.hasJSDocNodes(current) && ts.forEach(current.jsDoc, getContainingChild) || ts.forEachChild(current, getContainingChild);
87391                     if (!child) {
87392                         return current;
87393                     }
87394                     current = child;
87395                 }
87396             }
87397         }
87398         function getLibFileFromReference(ref) {
87399             var libName = ts.toFileNameLowerCase(ref.fileName);
87400             var libFileName = ts.libMap.get(libName);
87401             if (libFileName) {
87402                 return getSourceFile(ts.combinePaths(defaultLibraryPath, libFileName));
87403             }
87404         }
87405         function getSourceFileFromReference(referencingFile, ref) {
87406             return getSourceFileFromReferenceWorker(resolveTripleslashReference(ref.fileName, referencingFile.fileName), function (fileName) { return filesByName.get(toPath(fileName)) || undefined; });
87407         }
87408         function getSourceFileFromReferenceWorker(fileName, getSourceFile, fail, refFile) {
87409             if (ts.hasExtension(fileName)) {
87410                 var canonicalFileName_1 = host.getCanonicalFileName(fileName);
87411                 if (!options.allowNonTsExtensions && !ts.forEach(supportedExtensionsWithJsonIfResolveJsonModule, function (extension) { return ts.fileExtensionIs(canonicalFileName_1, extension); })) {
87412                     if (fail) {
87413                         if (ts.hasJSFileExtension(canonicalFileName_1)) {
87414                             fail(ts.Diagnostics.File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option, fileName);
87415                         }
87416                         else {
87417                             fail(ts.Diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1, fileName, "'" + supportedExtensions.join("', '") + "'");
87418                         }
87419                     }
87420                     return undefined;
87421                 }
87422                 var sourceFile = getSourceFile(fileName);
87423                 if (fail) {
87424                     if (!sourceFile) {
87425                         var redirect = getProjectReferenceRedirect(fileName);
87426                         if (redirect) {
87427                             fail(ts.Diagnostics.Output_file_0_has_not_been_built_from_source_file_1, redirect, fileName);
87428                         }
87429                         else {
87430                             fail(ts.Diagnostics.File_0_not_found, fileName);
87431                         }
87432                     }
87433                     else if (refFile && canonicalFileName_1 === host.getCanonicalFileName(refFile.fileName)) {
87434                         fail(ts.Diagnostics.A_file_cannot_have_a_reference_to_itself);
87435                     }
87436                 }
87437                 return sourceFile;
87438             }
87439             else {
87440                 var sourceFileNoExtension = options.allowNonTsExtensions && getSourceFile(fileName);
87441                 if (sourceFileNoExtension)
87442                     return sourceFileNoExtension;
87443                 if (fail && options.allowNonTsExtensions) {
87444                     fail(ts.Diagnostics.File_0_not_found, fileName);
87445                     return undefined;
87446                 }
87447                 var sourceFileWithAddedExtension = ts.forEach(supportedExtensions, function (extension) { return getSourceFile(fileName + extension); });
87448                 if (fail && !sourceFileWithAddedExtension)
87449                     fail(ts.Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1, fileName, "'" + supportedExtensions.join("', '") + "'");
87450                 return sourceFileWithAddedExtension;
87451             }
87452         }
87453         function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile) {
87454             getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, packageId); }, function (diagnostic) {
87455                 var args = [];
87456                 for (var _i = 1; _i < arguments.length; _i++) {
87457                     args[_i - 1] = arguments[_i];
87458                 }
87459                 return fileProcessingDiagnostics.add(createRefFileDiagnostic.apply(void 0, __spreadArrays([refFile, diagnostic], args)));
87460             }, refFile && refFile.file);
87461         }
87462         function reportFileNamesDifferOnlyInCasingError(fileName, existingFile, refFile) {
87463             var refs = !refFile ? refFileMap && refFileMap.get(existingFile.path) : undefined;
87464             var refToReportErrorOn = refs && ts.find(refs, function (ref) { return ref.referencedFileName === existingFile.fileName; });
87465             fileProcessingDiagnostics.add(refToReportErrorOn ?
87466                 createFileDiagnosticAtReference(refToReportErrorOn, ts.Diagnostics.Already_included_file_name_0_differs_from_file_name_1_only_in_casing, existingFile.fileName, fileName) :
87467                 createRefFileDiagnostic(refFile, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFile.fileName));
87468         }
87469         function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) {
87470             var redirect = Object.create(redirectTarget);
87471             redirect.fileName = fileName;
87472             redirect.path = path;
87473             redirect.resolvedPath = resolvedPath;
87474             redirect.originalFileName = originalFileName;
87475             redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected };
87476             sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
87477             Object.defineProperties(redirect, {
87478                 id: {
87479                     get: function () { return this.redirectInfo.redirectTarget.id; },
87480                     set: function (value) { this.redirectInfo.redirectTarget.id = value; },
87481                 },
87482                 symbol: {
87483                     get: function () { return this.redirectInfo.redirectTarget.symbol; },
87484                     set: function (value) { this.redirectInfo.redirectTarget.symbol = value; },
87485                 },
87486             });
87487             return redirect;
87488         }
87489         function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) {
87490             ts.tracing.push("program", "findSourceFile", {
87491                 fileName: fileName,
87492                 isDefaultLib: isDefaultLib || undefined,
87493                 refKind: refFile ? ts.RefFileKind[refFile.kind] : undefined,
87494             });
87495             var result = findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId);
87496             ts.tracing.pop();
87497             return result;
87498         }
87499         function findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) {
87500             if (useSourceOfProjectReferenceRedirect) {
87501                 var source = getSourceOfProjectReferenceRedirect(fileName);
87502                 if (!source &&
87503                     host.realpath &&
87504                     options.preserveSymlinks &&
87505                     ts.isDeclarationFileName(fileName) &&
87506                     ts.stringContains(fileName, ts.nodeModulesPathPart)) {
87507                     var realPath = host.realpath(fileName);
87508                     if (realPath !== fileName)
87509                         source = getSourceOfProjectReferenceRedirect(realPath);
87510                 }
87511                 if (source) {
87512                     var file_1 = ts.isString(source) ?
87513                         findSourceFile(source, toPath(source), isDefaultLib, ignoreNoDefaultLib, refFile, packageId) :
87514                         undefined;
87515                     if (file_1)
87516                         addFileToFilesByName(file_1, path, undefined);
87517                     return file_1;
87518                 }
87519             }
87520             var originalFileName = fileName;
87521             if (filesByName.has(path)) {
87522                 var file_2 = filesByName.get(path);
87523                 addFileToRefFileMap(fileName, file_2 || undefined, refFile);
87524                 if (file_2 && options.forceConsistentCasingInFileNames) {
87525                     var checkedName = file_2.fileName;
87526                     var isRedirect = toPath(checkedName) !== toPath(fileName);
87527                     if (isRedirect) {
87528                         fileName = getProjectReferenceRedirect(fileName) || fileName;
87529                     }
87530                     var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory);
87531                     var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory);
87532                     if (checkedAbsolutePath !== inputAbsolutePath) {
87533                         reportFileNamesDifferOnlyInCasingError(fileName, file_2, refFile);
87534                     }
87535                 }
87536                 if (file_2 && sourceFilesFoundSearchingNodeModules.get(file_2.path) && currentNodeModulesDepth === 0) {
87537                     sourceFilesFoundSearchingNodeModules.set(file_2.path, false);
87538                     if (!options.noResolve) {
87539                         processReferencedFiles(file_2, isDefaultLib);
87540                         processTypeReferenceDirectives(file_2);
87541                     }
87542                     if (!options.noLib) {
87543                         processLibReferenceDirectives(file_2);
87544                     }
87545                     modulesWithElidedImports.set(file_2.path, false);
87546                     processImportedModules(file_2);
87547                 }
87548                 else if (file_2 && modulesWithElidedImports.get(file_2.path)) {
87549                     if (currentNodeModulesDepth < maxNodeModuleJsDepth) {
87550                         modulesWithElidedImports.set(file_2.path, false);
87551                         processImportedModules(file_2);
87552                     }
87553                 }
87554                 return file_2 || undefined;
87555             }
87556             var redirectedPath;
87557             if (refFile && !useSourceOfProjectReferenceRedirect) {
87558                 var redirectProject = getProjectReferenceRedirectProject(fileName);
87559                 if (redirectProject) {
87560                     if (ts.outFile(redirectProject.commandLine.options)) {
87561                         return undefined;
87562                     }
87563                     var redirect = getProjectReferenceOutputName(redirectProject, fileName);
87564                     fileName = redirect;
87565                     redirectedPath = toPath(redirect);
87566                 }
87567             }
87568             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);
87569             if (packageId) {
87570                 var packageIdKey = ts.packageIdToString(packageId);
87571                 var fileFromPackageId = packageIdToSourceFile.get(packageIdKey);
87572                 if (fileFromPackageId) {
87573                     var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName);
87574                     redirectTargetsMap.add(fileFromPackageId.path, fileName);
87575                     addFileToFilesByName(dupFile, path, redirectedPath);
87576                     sourceFileToPackageName.set(path, packageId.name);
87577                     processingOtherFiles.push(dupFile);
87578                     return dupFile;
87579                 }
87580                 else if (file) {
87581                     packageIdToSourceFile.set(packageIdKey, file);
87582                     sourceFileToPackageName.set(path, packageId.name);
87583                 }
87584             }
87585             addFileToFilesByName(file, path, redirectedPath);
87586             if (file) {
87587                 sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
87588                 file.fileName = fileName;
87589                 file.path = path;
87590                 file.resolvedPath = toPath(fileName);
87591                 file.originalFileName = originalFileName;
87592                 addFileToRefFileMap(fileName, file, refFile);
87593                 if (host.useCaseSensitiveFileNames()) {
87594                     var pathLowerCase = ts.toFileNameLowerCase(path);
87595                     var existingFile = filesByNameIgnoreCase.get(pathLowerCase);
87596                     if (existingFile) {
87597                         reportFileNamesDifferOnlyInCasingError(fileName, existingFile, refFile);
87598                     }
87599                     else {
87600                         filesByNameIgnoreCase.set(pathLowerCase, file);
87601                     }
87602                 }
87603                 skipDefaultLib = skipDefaultLib || (file.hasNoDefaultLib && !ignoreNoDefaultLib);
87604                 if (!options.noResolve) {
87605                     processReferencedFiles(file, isDefaultLib);
87606                     processTypeReferenceDirectives(file);
87607                 }
87608                 if (!options.noLib) {
87609                     processLibReferenceDirectives(file);
87610                 }
87611                 processImportedModules(file);
87612                 if (isDefaultLib) {
87613                     processingDefaultLibFiles.push(file);
87614                 }
87615                 else {
87616                     processingOtherFiles.push(file);
87617                 }
87618             }
87619             return file;
87620         }
87621         function addFileToRefFileMap(referencedFileName, file, refFile) {
87622             if (refFile && file) {
87623                 (refFileMap || (refFileMap = ts.createMultiMap())).add(file.path, {
87624                     referencedFileName: referencedFileName,
87625                     kind: refFile.kind,
87626                     index: refFile.index,
87627                     file: refFile.file.path
87628                 });
87629             }
87630         }
87631         function addFileToFilesByName(file, path, redirectedPath) {
87632             if (redirectedPath) {
87633                 filesByName.set(redirectedPath, file);
87634                 filesByName.set(path, file || false);
87635             }
87636             else {
87637                 filesByName.set(path, file);
87638             }
87639         }
87640         function getProjectReferenceRedirect(fileName) {
87641             var referencedProject = getProjectReferenceRedirectProject(fileName);
87642             return referencedProject && getProjectReferenceOutputName(referencedProject, fileName);
87643         }
87644         function getProjectReferenceRedirectProject(fileName) {
87645             if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts") || ts.fileExtensionIs(fileName, ".json")) {
87646                 return undefined;
87647             }
87648             return getResolvedProjectReferenceToRedirect(fileName);
87649         }
87650         function getProjectReferenceOutputName(referencedProject, fileName) {
87651             var out = ts.outFile(referencedProject.commandLine.options);
87652             return out ?
87653                 ts.changeExtension(out, ".d.ts") :
87654                 ts.getOutputDeclarationFileName(fileName, referencedProject.commandLine, !host.useCaseSensitiveFileNames());
87655         }
87656         function getResolvedProjectReferenceToRedirect(fileName) {
87657             if (mapFromFileToProjectReferenceRedirects === undefined) {
87658                 mapFromFileToProjectReferenceRedirects = new ts.Map();
87659                 forEachResolvedProjectReference(function (referencedProject) {
87660                     if (toPath(options.configFilePath) !== referencedProject.sourceFile.path) {
87661                         referencedProject.commandLine.fileNames.forEach(function (f) {
87662                             return mapFromFileToProjectReferenceRedirects.set(toPath(f), referencedProject.sourceFile.path);
87663                         });
87664                     }
87665                 });
87666             }
87667             var referencedProjectPath = mapFromFileToProjectReferenceRedirects.get(toPath(fileName));
87668             return referencedProjectPath && getResolvedProjectReferenceByPath(referencedProjectPath);
87669         }
87670         function forEachResolvedProjectReference(cb) {
87671             return ts.forEachResolvedProjectReference(resolvedProjectReferences, cb);
87672         }
87673         function getSourceOfProjectReferenceRedirect(file) {
87674             if (!ts.isDeclarationFileName(file))
87675                 return undefined;
87676             if (mapFromToProjectReferenceRedirectSource === undefined) {
87677                 mapFromToProjectReferenceRedirectSource = new ts.Map();
87678                 forEachResolvedProjectReference(function (resolvedRef) {
87679                     var out = ts.outFile(resolvedRef.commandLine.options);
87680                     if (out) {
87681                         var outputDts = ts.changeExtension(out, ".d.ts");
87682                         mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true);
87683                     }
87684                     else {
87685                         ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) {
87686                             if (!ts.fileExtensionIs(fileName, ".d.ts") && !ts.fileExtensionIs(fileName, ".json")) {
87687                                 var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames());
87688                                 mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName);
87689                             }
87690                         });
87691                     }
87692                 });
87693             }
87694             return mapFromToProjectReferenceRedirectSource.get(toPath(file));
87695         }
87696         function isSourceOfProjectReferenceRedirect(fileName) {
87697             return useSourceOfProjectReferenceRedirect && !!getResolvedProjectReferenceToRedirect(fileName);
87698         }
87699         function getResolvedProjectReferenceByPath(projectReferencePath) {
87700             if (!projectReferenceRedirects) {
87701                 return undefined;
87702             }
87703             return projectReferenceRedirects.get(projectReferencePath) || undefined;
87704         }
87705         function processReferencedFiles(file, isDefaultLib) {
87706             ts.forEach(file.referencedFiles, function (ref, index) {
87707                 var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName);
87708                 processSourceFile(referencedFileName, isDefaultLib, false, undefined, {
87709                     kind: ts.RefFileKind.ReferenceFile,
87710                     index: index,
87711                     file: file,
87712                     pos: ref.pos,
87713                     end: ref.end
87714                 });
87715             });
87716         }
87717         function processTypeReferenceDirectives(file) {
87718             var typeDirectives = ts.map(file.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
87719             if (!typeDirectives) {
87720                 return;
87721             }
87722             var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file);
87723             for (var i = 0; i < typeDirectives.length; i++) {
87724                 var ref = file.typeReferenceDirectives[i];
87725                 var resolvedTypeReferenceDirective = resolutions[i];
87726                 var fileName = ts.toFileNameLowerCase(ref.fileName);
87727                 ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
87728                 processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, {
87729                     kind: ts.RefFileKind.TypeReferenceDirective,
87730                     index: i,
87731                     file: file,
87732                     pos: ref.pos,
87733                     end: ref.end
87734                 });
87735             }
87736         }
87737         function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) {
87738             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 });
87739             processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, refFile);
87740             ts.tracing.pop();
87741         }
87742         function processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) {
87743             var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective);
87744             if (previousResolution && previousResolution.primary) {
87745                 return;
87746             }
87747             var saveResolution = true;
87748             if (resolvedTypeReferenceDirective) {
87749                 if (resolvedTypeReferenceDirective.isExternalLibraryImport)
87750                     currentNodeModulesDepth++;
87751                 if (resolvedTypeReferenceDirective.primary) {
87752                     processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, refFile);
87753                 }
87754                 else {
87755                     if (previousResolution) {
87756                         if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) {
87757                             var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName);
87758                             var existingFile_1 = getSourceFile(previousResolution.resolvedFileName);
87759                             if (otherFileText !== existingFile_1.text) {
87760                                 var refs = !refFile ? refFileMap && refFileMap.get(existingFile_1.path) : undefined;
87761                                 var refToReportErrorOn = refs && ts.find(refs, function (ref) { return ref.referencedFileName === existingFile_1.fileName; });
87762                                 fileProcessingDiagnostics.add(refToReportErrorOn ?
87763                                     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) :
87764                                     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));
87765                             }
87766                         }
87767                         saveResolution = false;
87768                     }
87769                     else {
87770                         processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, refFile);
87771                     }
87772                 }
87773                 if (resolvedTypeReferenceDirective.isExternalLibraryImport)
87774                     currentNodeModulesDepth--;
87775             }
87776             else {
87777                 fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective));
87778             }
87779             if (saveResolution) {
87780                 resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective);
87781             }
87782         }
87783         function processLibReferenceDirectives(file) {
87784             ts.forEach(file.libReferenceDirectives, function (libReference) {
87785                 var libName = ts.toFileNameLowerCase(libReference.fileName);
87786                 var libFileName = ts.libMap.get(libName);
87787                 if (libFileName) {
87788                     processRootFile(ts.combinePaths(defaultLibraryPath, libFileName), true, true);
87789                 }
87790                 else {
87791                     var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts");
87792                     var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity);
87793                     var message = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0;
87794                     fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, libReference.pos, libReference.end - libReference.pos, message, libName, suggestion));
87795                 }
87796             });
87797         }
87798         function createRefFileDiagnostic(refFile, message) {
87799             var args = [];
87800             for (var _i = 2; _i < arguments.length; _i++) {
87801                 args[_i - 2] = arguments[_i];
87802             }
87803             if (!refFile) {
87804                 return ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args));
87805             }
87806             else {
87807                 return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile.file, refFile.pos, refFile.end - refFile.pos, message], args));
87808             }
87809         }
87810         function getCanonicalFileName(fileName) {
87811             return host.getCanonicalFileName(fileName);
87812         }
87813         function processImportedModules(file) {
87814             collectExternalModuleReferences(file);
87815             if (file.imports.length || file.moduleAugmentations.length) {
87816                 var moduleNames = getModuleNames(file);
87817                 var resolutions = resolveModuleNamesReusingOldState(moduleNames, file);
87818                 ts.Debug.assert(resolutions.length === moduleNames.length);
87819                 for (var i = 0; i < moduleNames.length; i++) {
87820                     var resolution = resolutions[i];
87821                     ts.setResolvedModule(file, moduleNames[i], resolution);
87822                     if (!resolution) {
87823                         continue;
87824                     }
87825                     var isFromNodeModulesSearch = resolution.isExternalLibraryImport;
87826                     var isJsFile = !ts.resolutionExtensionIsTSOrJson(resolution.extension);
87827                     var isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile;
87828                     var resolvedFileName = resolution.resolvedFileName;
87829                     if (isFromNodeModulesSearch) {
87830                         currentNodeModulesDepth++;
87831                     }
87832                     var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth;
87833                     var shouldAddFile = resolvedFileName
87834                         && !getResolutionDiagnostic(options, resolution)
87835                         && !options.noResolve
87836                         && i < file.imports.length
87837                         && !elideImport
87838                         && !(isJsFile && !ts.getAllowJSCompilerOption(options))
87839                         && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 4194304));
87840                     if (elideImport) {
87841                         modulesWithElidedImports.set(file.path, true);
87842                     }
87843                     else if (shouldAddFile) {
87844                         var path = toPath(resolvedFileName);
87845                         var pos = ts.skipTrivia(file.text, file.imports[i].pos);
87846                         findSourceFile(resolvedFileName, path, false, false, {
87847                             kind: ts.RefFileKind.Import,
87848                             index: i,
87849                             file: file,
87850                             pos: pos,
87851                             end: file.imports[i].end
87852                         }, resolution.packageId);
87853                     }
87854                     if (isFromNodeModulesSearch) {
87855                         currentNodeModulesDepth--;
87856                     }
87857                 }
87858             }
87859             else {
87860                 file.resolvedModules = undefined;
87861             }
87862         }
87863         function computeCommonSourceDirectory(sourceFiles) {
87864             var fileNames = ts.mapDefined(sourceFiles, function (file) { return file.isDeclarationFile ? undefined : file.fileName; });
87865             return computeCommonSourceDirectoryOfFilenames(fileNames, currentDirectory, getCanonicalFileName);
87866         }
87867         function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) {
87868             var allFilesBelongToPath = true;
87869             var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory));
87870             var rootPaths;
87871             for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) {
87872                 var sourceFile = sourceFiles_2[_i];
87873                 if (!sourceFile.isDeclarationFile) {
87874                     var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
87875                     if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) {
87876                         if (!rootPaths)
87877                             rootPaths = new ts.Set(rootNames.map(toPath));
87878                         addProgramDiagnosticAtRefPath(sourceFile, rootPaths, ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory);
87879                         allFilesBelongToPath = false;
87880                     }
87881                 }
87882             }
87883             return allFilesBelongToPath;
87884         }
87885         function parseProjectReferenceConfigFile(ref) {
87886             if (!projectReferenceRedirects) {
87887                 projectReferenceRedirects = new ts.Map();
87888             }
87889             var refPath = resolveProjectReferencePath(ref);
87890             var sourceFilePath = toPath(refPath);
87891             var fromCache = projectReferenceRedirects.get(sourceFilePath);
87892             if (fromCache !== undefined) {
87893                 return fromCache || undefined;
87894             }
87895             var commandLine;
87896             var sourceFile;
87897             if (host.getParsedCommandLine) {
87898                 commandLine = host.getParsedCommandLine(refPath);
87899                 if (!commandLine) {
87900                     addFileToFilesByName(undefined, sourceFilePath, undefined);
87901                     projectReferenceRedirects.set(sourceFilePath, false);
87902                     return undefined;
87903                 }
87904                 sourceFile = ts.Debug.checkDefined(commandLine.options.configFile);
87905                 ts.Debug.assert(!sourceFile.path || sourceFile.path === sourceFilePath);
87906                 addFileToFilesByName(sourceFile, sourceFilePath, undefined);
87907             }
87908             else {
87909                 var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory());
87910                 sourceFile = host.getSourceFile(refPath, 100);
87911                 addFileToFilesByName(sourceFile, sourceFilePath, undefined);
87912                 if (sourceFile === undefined) {
87913                     projectReferenceRedirects.set(sourceFilePath, false);
87914                     return undefined;
87915                 }
87916                 commandLine = ts.parseJsonSourceFileConfigFileContent(sourceFile, configParsingHost, basePath, undefined, refPath);
87917             }
87918             sourceFile.fileName = refPath;
87919             sourceFile.path = sourceFilePath;
87920             sourceFile.resolvedPath = sourceFilePath;
87921             sourceFile.originalFileName = refPath;
87922             var resolvedRef = { commandLine: commandLine, sourceFile: sourceFile };
87923             projectReferenceRedirects.set(sourceFilePath, resolvedRef);
87924             if (commandLine.projectReferences) {
87925                 resolvedRef.references = commandLine.projectReferences.map(parseProjectReferenceConfigFile);
87926             }
87927             return resolvedRef;
87928         }
87929         function verifyCompilerOptions() {
87930             if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) {
87931                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks");
87932             }
87933             if (options.isolatedModules) {
87934                 if (options.out) {
87935                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules");
87936                 }
87937                 if (options.outFile) {
87938                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules");
87939                 }
87940             }
87941             if (options.inlineSourceMap) {
87942                 if (options.sourceMap) {
87943                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap");
87944                 }
87945                 if (options.mapRoot) {
87946                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap");
87947                 }
87948             }
87949             if (options.composite) {
87950                 if (options.declaration === false) {
87951                     createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_declaration_emit, "declaration");
87952                 }
87953                 if (options.incremental === false) {
87954                     createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_incremental_compilation, "declaration");
87955                 }
87956             }
87957             var outputFile = ts.outFile(options);
87958             if (options.tsBuildInfoFile) {
87959                 if (!ts.isIncrementalCompilation(options)) {
87960                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "tsBuildInfoFile", "incremental", "composite");
87961                 }
87962             }
87963             else if (options.incremental && !outputFile && !options.configFilePath) {
87964                 programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified));
87965             }
87966             verifyProjectReferences();
87967             if (options.composite) {
87968                 var rootPaths = new ts.Set(rootNames.map(toPath));
87969                 for (var _i = 0, files_3 = files; _i < files_3.length; _i++) {
87970                     var file = files_3[_i];
87971                     if (ts.sourceFileMayBeEmitted(file, program) && !rootPaths.has(file.path)) {
87972                         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 || "");
87973                     }
87974                 }
87975             }
87976             if (options.paths) {
87977                 for (var key in options.paths) {
87978                     if (!ts.hasProperty(options.paths, key)) {
87979                         continue;
87980                     }
87981                     if (!ts.hasZeroOrOneAsteriskCharacter(key)) {
87982                         createDiagnosticForOptionPaths(true, key, ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, key);
87983                     }
87984                     if (ts.isArray(options.paths[key])) {
87985                         var len = options.paths[key].length;
87986                         if (len === 0) {
87987                             createDiagnosticForOptionPaths(false, key, ts.Diagnostics.Substitutions_for_pattern_0_shouldn_t_be_an_empty_array, key);
87988                         }
87989                         for (var i = 0; i < len; i++) {
87990                             var subst = options.paths[key][i];
87991                             var typeOfSubst = typeof subst;
87992                             if (typeOfSubst === "string") {
87993                                 if (!ts.hasZeroOrOneAsteriskCharacter(subst)) {
87994                                     createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character, subst, key);
87995                                 }
87996                                 if (!options.baseUrl && !ts.pathIsRelative(subst) && !ts.pathIsAbsolute(subst)) {
87997                                     createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Non_relative_paths_are_not_allowed_when_baseUrl_is_not_set_Did_you_forget_a_leading_Slash);
87998                                 }
87999                             }
88000                             else {
88001                                 createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2, subst, key, typeOfSubst);
88002                             }
88003                         }
88004                     }
88005                     else {
88006                         createDiagnosticForOptionPaths(false, key, ts.Diagnostics.Substitutions_for_pattern_0_should_be_an_array, key);
88007                     }
88008                 }
88009             }
88010             if (!options.sourceMap && !options.inlineSourceMap) {
88011                 if (options.inlineSources) {
88012                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided, "inlineSources");
88013                 }
88014                 if (options.sourceRoot) {
88015                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided, "sourceRoot");
88016                 }
88017             }
88018             if (options.out && options.outFile) {
88019                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile");
88020             }
88021             if (options.mapRoot && !(options.sourceMap || options.declarationMap)) {
88022                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "mapRoot", "sourceMap", "declarationMap");
88023             }
88024             if (options.declarationDir) {
88025                 if (!ts.getEmitDeclarations(options)) {
88026                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "declarationDir", "declaration", "composite");
88027                 }
88028                 if (outputFile) {
88029                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declarationDir", options.out ? "out" : "outFile");
88030                 }
88031             }
88032             if (options.declarationMap && !ts.getEmitDeclarations(options)) {
88033                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "declarationMap", "declaration", "composite");
88034             }
88035             if (options.lib && options.noLib) {
88036                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib");
88037             }
88038             if (options.noImplicitUseStrict && ts.getStrictOptionValue(options, "alwaysStrict")) {
88039                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict");
88040             }
88041             var languageVersion = options.target || 0;
88042             var firstNonAmbientExternalModuleSourceFile = ts.find(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile; });
88043             if (options.isolatedModules) {
88044                 if (options.module === ts.ModuleKind.None && languageVersion < 2) {
88045                     createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target");
88046                 }
88047                 var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6; });
88048                 if (firstNonExternalModuleSourceFile) {
88049                     var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
88050                     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)));
88051                 }
88052             }
88053             else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 && options.module === ts.ModuleKind.None) {
88054                 var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
88055                 programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none));
88056             }
88057             if (outputFile && !options.emitDeclarationOnly) {
88058                 if (options.module && !(options.module === ts.ModuleKind.AMD || options.module === ts.ModuleKind.System)) {
88059                     createDiagnosticForOptionName(ts.Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile", "module");
88060                 }
88061                 else if (options.module === undefined && firstNonAmbientExternalModuleSourceFile) {
88062                     var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
88063                     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"));
88064                 }
88065             }
88066             if (options.resolveJsonModule) {
88067                 if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs) {
88068                     createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule");
88069                 }
88070                 else if (!ts.hasJsonModuleEmitEnabled(options)) {
88071                     createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_esNext, "resolveJsonModule", "module");
88072                 }
88073             }
88074             if (options.outDir ||
88075                 options.sourceRoot ||
88076                 options.mapRoot) {
88077                 var dir = getCommonSourceDirectory();
88078                 if (options.outDir && dir === "" && files.some(function (file) { return ts.getRootLength(file.fileName) > 1; })) {
88079                     createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir");
88080                 }
88081             }
88082             if (options.useDefineForClassFields && languageVersion === 0) {
88083                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields");
88084             }
88085             if (options.checkJs && !ts.getAllowJSCompilerOption(options)) {
88086                 programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs"));
88087             }
88088             if (options.emitDeclarationOnly) {
88089                 if (!ts.getEmitDeclarations(options)) {
88090                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "emitDeclarationOnly", "declaration", "composite");
88091                 }
88092                 if (options.noEmit) {
88093                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "emitDeclarationOnly", "noEmit");
88094                 }
88095             }
88096             if (options.emitDecoratorMetadata &&
88097                 !options.experimentalDecorators) {
88098                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators");
88099             }
88100             if (options.jsxFactory) {
88101                 if (options.reactNamespace) {
88102                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory");
88103                 }
88104                 if (options.jsx === 4 || options.jsx === 5) {
88105                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFactory", ts.inverseJsxOptionMap.get("" + options.jsx));
88106                 }
88107                 if (!ts.parseIsolatedEntityName(options.jsxFactory, languageVersion)) {
88108                     createOptionValueDiagnostic("jsxFactory", ts.Diagnostics.Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name, options.jsxFactory);
88109                 }
88110             }
88111             else if (options.reactNamespace && !ts.isIdentifierText(options.reactNamespace, languageVersion)) {
88112                 createOptionValueDiagnostic("reactNamespace", ts.Diagnostics.Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier, options.reactNamespace);
88113             }
88114             if (options.jsxFragmentFactory) {
88115                 if (!options.jsxFactory) {
88116                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "jsxFragmentFactory", "jsxFactory");
88117                 }
88118                 if (options.jsx === 4 || options.jsx === 5) {
88119                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFragmentFactory", ts.inverseJsxOptionMap.get("" + options.jsx));
88120                 }
88121                 if (!ts.parseIsolatedEntityName(options.jsxFragmentFactory, languageVersion)) {
88122                     createOptionValueDiagnostic("jsxFragmentFactory", ts.Diagnostics.Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name, options.jsxFragmentFactory);
88123                 }
88124             }
88125             if (options.reactNamespace) {
88126                 if (options.jsx === 4 || options.jsx === 5) {
88127                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "reactNamespace", ts.inverseJsxOptionMap.get("" + options.jsx));
88128                 }
88129             }
88130             if (options.jsxImportSource) {
88131                 if (options.jsx === 2) {
88132                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxImportSource", ts.inverseJsxOptionMap.get("" + options.jsx));
88133                 }
88134             }
88135             if (!options.noEmit && !options.suppressOutputPathCheck) {
88136                 var emitHost = getEmitHost();
88137                 var emitFilesSeen_1 = new ts.Set();
88138                 ts.forEachEmittedFile(emitHost, function (emitFileNames) {
88139                     if (!options.emitDeclarationOnly) {
88140                         verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1);
88141                     }
88142                     verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1);
88143                 });
88144             }
88145             function verifyEmitFilePath(emitFileName, emitFilesSeen) {
88146                 if (emitFileName) {
88147                     var emitFilePath = toPath(emitFileName);
88148                     if (filesByName.has(emitFilePath)) {
88149                         var chain = void 0;
88150                         if (!options.configFilePath) {
88151                             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);
88152                         }
88153                         chain = ts.chainDiagnosticMessages(chain, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName);
88154                         blockEmittingOfFile(emitFileName, ts.createCompilerDiagnosticFromMessageChain(chain));
88155                     }
88156                     var emitFileKey = !host.useCaseSensitiveFileNames() ? ts.toFileNameLowerCase(emitFilePath) : emitFilePath;
88157                     if (emitFilesSeen.has(emitFileKey)) {
88158                         blockEmittingOfFile(emitFileName, ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, emitFileName));
88159                     }
88160                     else {
88161                         emitFilesSeen.add(emitFileKey);
88162                     }
88163                 }
88164             }
88165         }
88166         function createFileDiagnosticAtReference(refPathToReportErrorOn, message) {
88167             var _a, _b;
88168             var args = [];
88169             for (var _i = 2; _i < arguments.length; _i++) {
88170                 args[_i - 2] = arguments[_i];
88171             }
88172             var refFile = ts.Debug.checkDefined(getSourceFileByPath(refPathToReportErrorOn.file));
88173             var kind = refPathToReportErrorOn.kind, index = refPathToReportErrorOn.index;
88174             var pos, end;
88175             switch (kind) {
88176                 case ts.RefFileKind.Import:
88177                     pos = ts.skipTrivia(refFile.text, refFile.imports[index].pos);
88178                     end = refFile.imports[index].end;
88179                     break;
88180                 case ts.RefFileKind.ReferenceFile:
88181                     (_a = refFile.referencedFiles[index], pos = _a.pos, end = _a.end);
88182                     break;
88183                 case ts.RefFileKind.TypeReferenceDirective:
88184                     (_b = refFile.typeReferenceDirectives[index], pos = _b.pos, end = _b.end);
88185                     break;
88186                 default:
88187                     return ts.Debug.assertNever(kind);
88188             }
88189             return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, pos, end - pos, message], args));
88190         }
88191         function addProgramDiagnosticAtRefPath(file, rootPaths, message) {
88192             var args = [];
88193             for (var _i = 3; _i < arguments.length; _i++) {
88194                 args[_i - 3] = arguments[_i];
88195             }
88196             var refPaths = refFileMap === null || refFileMap === void 0 ? void 0 : refFileMap.get(file.path);
88197             var refPathToReportErrorOn = ts.forEach(refPaths, function (refPath) { return rootPaths.has(refPath.file) ? refPath : undefined; }) ||
88198                 ts.elementAt(refPaths, 0);
88199             programDiagnostics.add(refPathToReportErrorOn ? createFileDiagnosticAtReference.apply(void 0, __spreadArrays([refPathToReportErrorOn, message], args)) : ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)));
88200         }
88201         function verifyProjectReferences() {
88202             var buildInfoPath = !options.suppressOutputPathCheck ? ts.getTsBuildInfoEmitOutputFilePath(options) : undefined;
88203             forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, parent, index) {
88204                 var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index];
88205                 var parentFile = parent && parent.sourceFile;
88206                 if (!resolvedRef) {
88207                     createDiagnosticForReference(parentFile, index, ts.Diagnostics.File_0_not_found, ref.path);
88208                     return;
88209                 }
88210                 var options = resolvedRef.commandLine.options;
88211                 if (!options.composite || options.noEmit) {
88212                     var inputs = parent ? parent.commandLine.fileNames : rootNames;
88213                     if (inputs.length) {
88214                         if (!options.composite)
88215                             createDiagnosticForReference(parentFile, index, ts.Diagnostics.Referenced_project_0_must_have_setting_composite_Colon_true, ref.path);
88216                         if (options.noEmit)
88217                             createDiagnosticForReference(parentFile, index, ts.Diagnostics.Referenced_project_0_may_not_disable_emit, ref.path);
88218                     }
88219                 }
88220                 if (ref.prepend) {
88221                     var out = ts.outFile(options);
88222                     if (out) {
88223                         if (!host.fileExists(out)) {
88224                             createDiagnosticForReference(parentFile, index, ts.Diagnostics.Output_file_0_from_project_1_does_not_exist, out, ref.path);
88225                         }
88226                     }
88227                     else {
88228                         createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path);
88229                     }
88230                 }
88231                 if (!parent && buildInfoPath && buildInfoPath === ts.getTsBuildInfoEmitOutputFilePath(options)) {
88232                     createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoPath, ref.path);
88233                     hasEmitBlockingDiagnostics.set(toPath(buildInfoPath), true);
88234                 }
88235             });
88236         }
88237         function createDiagnosticForOptionPathKeyValue(key, valueIndex, message, arg0, arg1, arg2) {
88238             var needCompilerDiagnostic = true;
88239             var pathsSyntax = getOptionPathsSyntax();
88240             for (var _i = 0, pathsSyntax_1 = pathsSyntax; _i < pathsSyntax_1.length; _i++) {
88241                 var pathProp = pathsSyntax_1[_i];
88242                 if (ts.isObjectLiteralExpression(pathProp.initializer)) {
88243                     for (var _a = 0, _b = ts.getPropertyAssignment(pathProp.initializer, key); _a < _b.length; _a++) {
88244                         var keyProps = _b[_a];
88245                         var initializer = keyProps.initializer;
88246                         if (ts.isArrayLiteralExpression(initializer) && initializer.elements.length > valueIndex) {
88247                             programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, initializer.elements[valueIndex], message, arg0, arg1, arg2));
88248                             needCompilerDiagnostic = false;
88249                         }
88250                     }
88251                 }
88252             }
88253             if (needCompilerDiagnostic) {
88254                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1, arg2));
88255             }
88256         }
88257         function createDiagnosticForOptionPaths(onKey, key, message, arg0) {
88258             var needCompilerDiagnostic = true;
88259             var pathsSyntax = getOptionPathsSyntax();
88260             for (var _i = 0, pathsSyntax_2 = pathsSyntax; _i < pathsSyntax_2.length; _i++) {
88261                 var pathProp = pathsSyntax_2[_i];
88262                 if (ts.isObjectLiteralExpression(pathProp.initializer) &&
88263                     createOptionDiagnosticInObjectLiteralSyntax(pathProp.initializer, onKey, key, undefined, message, arg0)) {
88264                     needCompilerDiagnostic = false;
88265                 }
88266             }
88267             if (needCompilerDiagnostic) {
88268                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0));
88269             }
88270         }
88271         function getOptionsSyntaxByName(name) {
88272             var compilerOptionsObjectLiteralSyntax = getCompilerOptionsObjectLiteralSyntax();
88273             if (compilerOptionsObjectLiteralSyntax) {
88274                 return ts.getPropertyAssignment(compilerOptionsObjectLiteralSyntax, name);
88275             }
88276             return undefined;
88277         }
88278         function getOptionPathsSyntax() {
88279             return getOptionsSyntaxByName("paths") || ts.emptyArray;
88280         }
88281         function createDiagnosticForOptionName(message, option1, option2, option3) {
88282             createDiagnosticForOption(true, option1, option2, message, option1, option2, option3);
88283         }
88284         function createOptionValueDiagnostic(option1, message, arg0) {
88285             createDiagnosticForOption(false, option1, undefined, message, arg0);
88286         }
88287         function createDiagnosticForReference(sourceFile, index, message, arg0, arg1) {
88288             var referencesSyntax = ts.firstDefined(ts.getTsConfigPropArray(sourceFile || options.configFile, "references"), function (property) { return ts.isArrayLiteralExpression(property.initializer) ? property.initializer : undefined; });
88289             if (referencesSyntax && referencesSyntax.elements.length > index) {
88290                 programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(sourceFile || options.configFile, referencesSyntax.elements[index], message, arg0, arg1));
88291             }
88292             else {
88293                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1));
88294             }
88295         }
88296         function createDiagnosticForOption(onKey, option1, option2, message, arg0, arg1, arg2) {
88297             var compilerOptionsObjectLiteralSyntax = getCompilerOptionsObjectLiteralSyntax();
88298             var needCompilerDiagnostic = !compilerOptionsObjectLiteralSyntax ||
88299                 !createOptionDiagnosticInObjectLiteralSyntax(compilerOptionsObjectLiteralSyntax, onKey, option1, option2, message, arg0, arg1, arg2);
88300             if (needCompilerDiagnostic) {
88301                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1, arg2));
88302             }
88303         }
88304         function getCompilerOptionsObjectLiteralSyntax() {
88305             if (_compilerOptionsObjectLiteralSyntax === undefined) {
88306                 _compilerOptionsObjectLiteralSyntax = null;
88307                 var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile);
88308                 if (jsonObjectLiteral) {
88309                     for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "compilerOptions"); _i < _a.length; _i++) {
88310                         var prop = _a[_i];
88311                         if (ts.isObjectLiteralExpression(prop.initializer)) {
88312                             _compilerOptionsObjectLiteralSyntax = prop.initializer;
88313                             break;
88314                         }
88315                     }
88316                 }
88317             }
88318             return _compilerOptionsObjectLiteralSyntax;
88319         }
88320         function createOptionDiagnosticInObjectLiteralSyntax(objectLiteral, onKey, key1, key2, message, arg0, arg1, arg2) {
88321             var props = ts.getPropertyAssignment(objectLiteral, key1, key2);
88322             for (var _i = 0, props_3 = props; _i < props_3.length; _i++) {
88323                 var prop = props_3[_i];
88324                 programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, onKey ? prop.name : prop.initializer, message, arg0, arg1, arg2));
88325             }
88326             return !!props.length;
88327         }
88328         function blockEmittingOfFile(emitFileName, diag) {
88329             hasEmitBlockingDiagnostics.set(toPath(emitFileName), true);
88330             programDiagnostics.add(diag);
88331         }
88332         function isEmittedFile(file) {
88333             if (options.noEmit) {
88334                 return false;
88335             }
88336             var filePath = toPath(file);
88337             if (getSourceFileByPath(filePath)) {
88338                 return false;
88339             }
88340             var out = ts.outFile(options);
88341             if (out) {
88342                 return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts");
88343             }
88344             if (options.declarationDir && ts.containsPath(options.declarationDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames())) {
88345                 return true;
88346             }
88347             if (options.outDir) {
88348                 return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames());
88349             }
88350             if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensions) || ts.fileExtensionIs(filePath, ".d.ts")) {
88351                 var filePathWithoutExtension = ts.removeFileExtension(filePath);
88352                 return !!getSourceFileByPath((filePathWithoutExtension + ".ts")) ||
88353                     !!getSourceFileByPath((filePathWithoutExtension + ".tsx"));
88354             }
88355             return false;
88356         }
88357         function isSameFile(file1, file2) {
88358             return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0;
88359         }
88360         function getSymlinkCache() {
88361             if (host.getSymlinkCache) {
88362                 return host.getSymlinkCache();
88363             }
88364             return symlinks || (symlinks = ts.discoverProbableSymlinks(files, getCanonicalFileName, host.getCurrentDirectory()));
88365         }
88366     }
88367     ts.createProgram = createProgram;
88368     function updateHostForUseSourceOfProjectReferenceRedirect(host) {
88369         var setOfDeclarationDirectories;
88370         var originalFileExists = host.compilerHost.fileExists;
88371         var originalDirectoryExists = host.compilerHost.directoryExists;
88372         var originalGetDirectories = host.compilerHost.getDirectories;
88373         var originalRealpath = host.compilerHost.realpath;
88374         if (!host.useSourceOfProjectReferenceRedirect)
88375             return { onProgramCreateComplete: ts.noop, fileExists: fileExists };
88376         host.compilerHost.fileExists = fileExists;
88377         var directoryExists;
88378         if (originalDirectoryExists) {
88379             directoryExists = host.compilerHost.directoryExists = function (path) {
88380                 if (originalDirectoryExists.call(host.compilerHost, path)) {
88381                     handleDirectoryCouldBeSymlink(path);
88382                     return true;
88383                 }
88384                 if (!host.getResolvedProjectReferences())
88385                     return false;
88386                 if (!setOfDeclarationDirectories) {
88387                     setOfDeclarationDirectories = new ts.Set();
88388                     host.forEachResolvedProjectReference(function (ref) {
88389                         var out = ts.outFile(ref.commandLine.options);
88390                         if (out) {
88391                             setOfDeclarationDirectories.add(ts.getDirectoryPath(host.toPath(out)));
88392                         }
88393                         else {
88394                             var declarationDir = ref.commandLine.options.declarationDir || ref.commandLine.options.outDir;
88395                             if (declarationDir) {
88396                                 setOfDeclarationDirectories.add(host.toPath(declarationDir));
88397                             }
88398                         }
88399                     });
88400                 }
88401                 return fileOrDirectoryExistsUsingSource(path, false);
88402             };
88403         }
88404         if (originalGetDirectories) {
88405             host.compilerHost.getDirectories = function (path) {
88406                 return !host.getResolvedProjectReferences() || (originalDirectoryExists && originalDirectoryExists.call(host.compilerHost, path)) ?
88407                     originalGetDirectories.call(host.compilerHost, path) :
88408                     [];
88409             };
88410         }
88411         if (originalRealpath) {
88412             host.compilerHost.realpath = function (s) {
88413                 var _a;
88414                 return ((_a = host.getSymlinkCache().getSymlinkedFiles()) === null || _a === void 0 ? void 0 : _a.get(host.toPath(s))) ||
88415                     originalRealpath.call(host.compilerHost, s);
88416             };
88417         }
88418         return { onProgramCreateComplete: onProgramCreateComplete, fileExists: fileExists, directoryExists: directoryExists };
88419         function onProgramCreateComplete() {
88420             host.compilerHost.fileExists = originalFileExists;
88421             host.compilerHost.directoryExists = originalDirectoryExists;
88422             host.compilerHost.getDirectories = originalGetDirectories;
88423         }
88424         function fileExists(file) {
88425             if (originalFileExists.call(host.compilerHost, file))
88426                 return true;
88427             if (!host.getResolvedProjectReferences())
88428                 return false;
88429             if (!ts.isDeclarationFileName(file))
88430                 return false;
88431             return fileOrDirectoryExistsUsingSource(file, true);
88432         }
88433         function fileExistsIfProjectReferenceDts(file) {
88434             var source = host.getSourceOfProjectReferenceRedirect(file);
88435             return source !== undefined ?
88436                 ts.isString(source) ? originalFileExists.call(host.compilerHost, source) : true :
88437                 undefined;
88438         }
88439         function directoryExistsIfProjectReferenceDeclDir(dir) {
88440             var dirPath = host.toPath(dir);
88441             var dirPathWithTrailingDirectorySeparator = "" + dirPath + ts.directorySeparator;
88442             return ts.forEachKey(setOfDeclarationDirectories, function (declDirPath) { return dirPath === declDirPath ||
88443                 ts.startsWith(declDirPath, dirPathWithTrailingDirectorySeparator) ||
88444                 ts.startsWith(dirPath, declDirPath + "/"); });
88445         }
88446         function handleDirectoryCouldBeSymlink(directory) {
88447             var _a;
88448             if (!host.getResolvedProjectReferences())
88449                 return;
88450             if (!originalRealpath || !ts.stringContains(directory, ts.nodeModulesPathPart))
88451                 return;
88452             var symlinkCache = host.getSymlinkCache();
88453             var directoryPath = ts.ensureTrailingDirectorySeparator(host.toPath(directory));
88454             if ((_a = symlinkCache.getSymlinkedDirectories()) === null || _a === void 0 ? void 0 : _a.has(directoryPath))
88455                 return;
88456             var real = ts.normalizePath(originalRealpath.call(host.compilerHost, directory));
88457             var realPath;
88458             if (real === directory ||
88459                 (realPath = ts.ensureTrailingDirectorySeparator(host.toPath(real))) === directoryPath) {
88460                 symlinkCache.setSymlinkedDirectory(directoryPath, false);
88461                 return;
88462             }
88463             symlinkCache.setSymlinkedDirectory(directoryPath, {
88464                 real: ts.ensureTrailingDirectorySeparator(real),
88465                 realPath: realPath
88466             });
88467         }
88468         function fileOrDirectoryExistsUsingSource(fileOrDirectory, isFile) {
88469             var _a;
88470             var fileOrDirectoryExistsUsingSource = isFile ?
88471                 function (file) { return fileExistsIfProjectReferenceDts(file); } :
88472                 function (dir) { return directoryExistsIfProjectReferenceDeclDir(dir); };
88473             var result = fileOrDirectoryExistsUsingSource(fileOrDirectory);
88474             if (result !== undefined)
88475                 return result;
88476             var symlinkCache = host.getSymlinkCache();
88477             var symlinkedDirectories = symlinkCache.getSymlinkedDirectories();
88478             if (!symlinkedDirectories)
88479                 return false;
88480             var fileOrDirectoryPath = host.toPath(fileOrDirectory);
88481             if (!ts.stringContains(fileOrDirectoryPath, ts.nodeModulesPathPart))
88482                 return false;
88483             if (isFile && ((_a = symlinkCache.getSymlinkedFiles()) === null || _a === void 0 ? void 0 : _a.has(fileOrDirectoryPath)))
88484                 return true;
88485             return ts.firstDefinedIterator(symlinkedDirectories.entries(), function (_a) {
88486                 var directoryPath = _a[0], symlinkedDirectory = _a[1];
88487                 if (!symlinkedDirectory || !ts.startsWith(fileOrDirectoryPath, directoryPath))
88488                     return undefined;
88489                 var result = fileOrDirectoryExistsUsingSource(fileOrDirectoryPath.replace(directoryPath, symlinkedDirectory.realPath));
88490                 if (isFile && result) {
88491                     var absolutePath = ts.getNormalizedAbsolutePath(fileOrDirectory, host.compilerHost.getCurrentDirectory());
88492                     symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "" + symlinkedDirectory.real + absolutePath.replace(new RegExp(directoryPath, "i"), ""));
88493                 }
88494                 return result;
88495             }) || false;
88496         }
88497     }
88498     ts.emitSkippedWithNoDiagnostics = { diagnostics: ts.emptyArray, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true };
88499     function handleNoEmitOptions(program, sourceFile, writeFile, cancellationToken) {
88500         var options = program.getCompilerOptions();
88501         if (options.noEmit) {
88502             program.getSemanticDiagnostics(sourceFile, cancellationToken);
88503             return sourceFile || ts.outFile(options) ?
88504                 ts.emitSkippedWithNoDiagnostics :
88505                 program.emitBuildInfo(writeFile, cancellationToken);
88506         }
88507         if (!options.noEmitOnError)
88508             return undefined;
88509         var diagnostics = __spreadArrays(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken));
88510         if (diagnostics.length === 0 && ts.getEmitDeclarations(program.getCompilerOptions())) {
88511             diagnostics = program.getDeclarationDiagnostics(undefined, cancellationToken);
88512         }
88513         if (!diagnostics.length)
88514             return undefined;
88515         var emittedFiles;
88516         if (!sourceFile && !ts.outFile(options)) {
88517             var emitResult = program.emitBuildInfo(writeFile, cancellationToken);
88518             if (emitResult.diagnostics)
88519                 diagnostics = __spreadArrays(diagnostics, emitResult.diagnostics);
88520             emittedFiles = emitResult.emittedFiles;
88521         }
88522         return { diagnostics: diagnostics, sourceMaps: undefined, emittedFiles: emittedFiles, emitSkipped: true };
88523     }
88524     ts.handleNoEmitOptions = handleNoEmitOptions;
88525     function filterSemanticDiagnotics(diagnostic, option) {
88526         return ts.filter(diagnostic, function (d) { return !d.skippedOn || !option[d.skippedOn]; });
88527     }
88528     ts.filterSemanticDiagnotics = filterSemanticDiagnotics;
88529     function parseConfigHostFromCompilerHostLike(host, directoryStructureHost) {
88530         if (directoryStructureHost === void 0) { directoryStructureHost = host; }
88531         return {
88532             fileExists: function (f) { return directoryStructureHost.fileExists(f); },
88533             readDirectory: function (root, extensions, excludes, includes, depth) {
88534                 ts.Debug.assertIsDefined(directoryStructureHost.readDirectory, "'CompilerHost.readDirectory' must be implemented to correctly process 'projectReferences'");
88535                 return directoryStructureHost.readDirectory(root, extensions, excludes, includes, depth);
88536             },
88537             readFile: function (f) { return directoryStructureHost.readFile(f); },
88538             useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(),
88539             getCurrentDirectory: function () { return host.getCurrentDirectory(); },
88540             onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic || ts.returnUndefined,
88541             trace: host.trace ? function (s) { return host.trace(s); } : undefined
88542         };
88543     }
88544     ts.parseConfigHostFromCompilerHostLike = parseConfigHostFromCompilerHostLike;
88545     function createPrependNodes(projectReferences, getCommandLine, readFile) {
88546         if (!projectReferences)
88547             return ts.emptyArray;
88548         var nodes;
88549         for (var i = 0; i < projectReferences.length; i++) {
88550             var ref = projectReferences[i];
88551             var resolvedRefOpts = getCommandLine(ref, i);
88552             if (ref.prepend && resolvedRefOpts && resolvedRefOpts.options) {
88553                 var out = ts.outFile(resolvedRefOpts.options);
88554                 if (!out)
88555                     continue;
88556                 var _a = ts.getOutputPathsForBundle(resolvedRefOpts.options, true), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
88557                 var node = ts.createInputFiles(readFile, jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath);
88558                 (nodes || (nodes = [])).push(node);
88559             }
88560         }
88561         return nodes || ts.emptyArray;
88562     }
88563     ts.createPrependNodes = createPrependNodes;
88564     function resolveProjectReferencePath(hostOrRef, ref) {
88565         var passedInRef = ref ? ref : hostOrRef;
88566         return ts.resolveConfigFileProjectName(passedInRef.path);
88567     }
88568     ts.resolveProjectReferencePath = resolveProjectReferencePath;
88569     function getResolutionDiagnostic(options, _a) {
88570         var extension = _a.extension;
88571         switch (extension) {
88572             case ".ts":
88573             case ".d.ts":
88574                 return undefined;
88575             case ".tsx":
88576                 return needJsx();
88577             case ".jsx":
88578                 return needJsx() || needAllowJs();
88579             case ".js":
88580                 return needAllowJs();
88581             case ".json":
88582                 return needResolveJsonModule();
88583         }
88584         function needJsx() {
88585             return options.jsx ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set;
88586         }
88587         function needAllowJs() {
88588             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;
88589         }
88590         function needResolveJsonModule() {
88591             return options.resolveJsonModule ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used;
88592         }
88593     }
88594     ts.getResolutionDiagnostic = getResolutionDiagnostic;
88595     function getModuleNames(_a) {
88596         var imports = _a.imports, moduleAugmentations = _a.moduleAugmentations;
88597         var res = imports.map(function (i) { return i.text; });
88598         for (var _i = 0, moduleAugmentations_1 = moduleAugmentations; _i < moduleAugmentations_1.length; _i++) {
88599             var aug = moduleAugmentations_1[_i];
88600             if (aug.kind === 10) {
88601                 res.push(aug.text);
88602             }
88603         }
88604         return res;
88605     }
88606 })(ts || (ts = {}));
88607 var ts;
88608 (function (ts) {
88609     function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) {
88610         var outputFiles = [];
88611         var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics, exportedModulesFromDeclarationEmit = _a.exportedModulesFromDeclarationEmit;
88612         return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics, exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit };
88613         function writeFile(fileName, text, writeByteOrderMark) {
88614             outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text });
88615         }
88616     }
88617     ts.getFileEmitOutput = getFileEmitOutput;
88618     var BuilderState;
88619     (function (BuilderState) {
88620         function getReferencedFileFromImportedModuleSymbol(symbol) {
88621             if (symbol.declarations && symbol.declarations[0]) {
88622                 var declarationSourceFile = ts.getSourceFileOfNode(symbol.declarations[0]);
88623                 return declarationSourceFile && declarationSourceFile.resolvedPath;
88624             }
88625         }
88626         function getReferencedFileFromImportLiteral(checker, importName) {
88627             var symbol = checker.getSymbolAtLocation(importName);
88628             return symbol && getReferencedFileFromImportedModuleSymbol(symbol);
88629         }
88630         function getReferencedFileFromFileName(program, fileName, sourceFileDirectory, getCanonicalFileName) {
88631             return ts.toPath(program.getProjectReferenceRedirect(fileName) || fileName, sourceFileDirectory, getCanonicalFileName);
88632         }
88633         function getReferencedFiles(program, sourceFile, getCanonicalFileName) {
88634             var referencedFiles;
88635             if (sourceFile.imports && sourceFile.imports.length > 0) {
88636                 var checker = program.getTypeChecker();
88637                 for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) {
88638                     var importName = _a[_i];
88639                     var declarationSourceFilePath = getReferencedFileFromImportLiteral(checker, importName);
88640                     if (declarationSourceFilePath) {
88641                         addReferencedFile(declarationSourceFilePath);
88642                     }
88643                 }
88644             }
88645             var sourceFileDirectory = ts.getDirectoryPath(sourceFile.resolvedPath);
88646             if (sourceFile.referencedFiles && sourceFile.referencedFiles.length > 0) {
88647                 for (var _b = 0, _c = sourceFile.referencedFiles; _b < _c.length; _b++) {
88648                     var referencedFile = _c[_b];
88649                     var referencedPath = getReferencedFileFromFileName(program, referencedFile.fileName, sourceFileDirectory, getCanonicalFileName);
88650                     addReferencedFile(referencedPath);
88651                 }
88652             }
88653             if (sourceFile.resolvedTypeReferenceDirectiveNames) {
88654                 sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (resolvedTypeReferenceDirective) {
88655                     if (!resolvedTypeReferenceDirective) {
88656                         return;
88657                     }
88658                     var fileName = resolvedTypeReferenceDirective.resolvedFileName;
88659                     var typeFilePath = getReferencedFileFromFileName(program, fileName, sourceFileDirectory, getCanonicalFileName);
88660                     addReferencedFile(typeFilePath);
88661                 });
88662             }
88663             if (sourceFile.moduleAugmentations.length) {
88664                 var checker = program.getTypeChecker();
88665                 for (var _d = 0, _e = sourceFile.moduleAugmentations; _d < _e.length; _d++) {
88666                     var moduleName = _e[_d];
88667                     if (!ts.isStringLiteral(moduleName)) {
88668                         continue;
88669                     }
88670                     var symbol = checker.getSymbolAtLocation(moduleName);
88671                     if (!symbol) {
88672                         continue;
88673                     }
88674                     addReferenceFromAmbientModule(symbol);
88675                 }
88676             }
88677             for (var _f = 0, _g = program.getTypeChecker().getAmbientModules(); _f < _g.length; _f++) {
88678                 var ambientModule = _g[_f];
88679                 if (ambientModule.declarations.length > 1) {
88680                     addReferenceFromAmbientModule(ambientModule);
88681                 }
88682             }
88683             return referencedFiles;
88684             function addReferenceFromAmbientModule(symbol) {
88685                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
88686                     var declaration = _a[_i];
88687                     var declarationSourceFile = ts.getSourceFileOfNode(declaration);
88688                     if (declarationSourceFile &&
88689                         declarationSourceFile !== sourceFile) {
88690                         addReferencedFile(declarationSourceFile.resolvedPath);
88691                     }
88692                 }
88693             }
88694             function addReferencedFile(referencedPath) {
88695                 (referencedFiles || (referencedFiles = new ts.Set())).add(referencedPath);
88696             }
88697         }
88698         function canReuseOldState(newReferencedMap, oldState) {
88699             return oldState && !oldState.referencedMap === !newReferencedMap;
88700         }
88701         BuilderState.canReuseOldState = canReuseOldState;
88702         function create(newProgram, getCanonicalFileName, oldState) {
88703             var fileInfos = new ts.Map();
88704             var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? new ts.Map() : undefined;
88705             var exportedModulesMap = referencedMap ? new ts.Map() : undefined;
88706             var hasCalledUpdateShapeSignature = new ts.Set();
88707             var useOldState = canReuseOldState(referencedMap, oldState);
88708             newProgram.getTypeChecker();
88709             for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
88710                 var sourceFile = _a[_i];
88711                 var version_2 = ts.Debug.checkDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set");
88712                 var oldInfo = useOldState ? oldState.fileInfos.get(sourceFile.resolvedPath) : undefined;
88713                 if (referencedMap) {
88714                     var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName);
88715                     if (newReferences) {
88716                         referencedMap.set(sourceFile.resolvedPath, newReferences);
88717                     }
88718                     if (useOldState) {
88719                         var exportedModules = oldState.exportedModulesMap.get(sourceFile.resolvedPath);
88720                         if (exportedModules) {
88721                             exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
88722                         }
88723                     }
88724                 }
88725                 fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) });
88726             }
88727             return {
88728                 fileInfos: fileInfos,
88729                 referencedMap: referencedMap,
88730                 exportedModulesMap: exportedModulesMap,
88731                 hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature
88732             };
88733         }
88734         BuilderState.create = create;
88735         function releaseCache(state) {
88736             state.allFilesExcludingDefaultLibraryFile = undefined;
88737             state.allFileNames = undefined;
88738         }
88739         BuilderState.releaseCache = releaseCache;
88740         function clone(state) {
88741             return {
88742                 fileInfos: new ts.Map(state.fileInfos),
88743                 referencedMap: state.referencedMap && new ts.Map(state.referencedMap),
88744                 exportedModulesMap: state.exportedModulesMap && new ts.Map(state.exportedModulesMap),
88745                 hasCalledUpdateShapeSignature: new ts.Set(state.hasCalledUpdateShapeSignature),
88746             };
88747         }
88748         BuilderState.clone = clone;
88749         function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, cacheToUpdateSignature, exportedModulesMapCache) {
88750             var signatureCache = cacheToUpdateSignature || new ts.Map();
88751             var sourceFile = programOfThisState.getSourceFileByPath(path);
88752             if (!sourceFile) {
88753                 return ts.emptyArray;
88754             }
88755             if (!updateShapeSignature(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache)) {
88756                 return [sourceFile];
88757             }
88758             var result = (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache);
88759             if (!cacheToUpdateSignature) {
88760                 updateSignaturesFromCache(state, signatureCache);
88761             }
88762             return result;
88763         }
88764         BuilderState.getFilesAffectedBy = getFilesAffectedBy;
88765         function updateSignaturesFromCache(state, signatureCache) {
88766             signatureCache.forEach(function (signature, path) { return updateSignatureOfFile(state, signature, path); });
88767         }
88768         BuilderState.updateSignaturesFromCache = updateSignaturesFromCache;
88769         function updateSignatureOfFile(state, signature, path) {
88770             state.fileInfos.get(path).signature = signature;
88771             state.hasCalledUpdateShapeSignature.add(path);
88772         }
88773         BuilderState.updateSignatureOfFile = updateSignatureOfFile;
88774         function updateShapeSignature(state, programOfThisState, sourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) {
88775             ts.Debug.assert(!!sourceFile);
88776             ts.Debug.assert(!exportedModulesMapCache || !!state.exportedModulesMap, "Compute visible to outside map only if visibleToOutsideReferencedMap present in the state");
88777             if (state.hasCalledUpdateShapeSignature.has(sourceFile.resolvedPath) || cacheToUpdateSignature.has(sourceFile.resolvedPath)) {
88778                 return false;
88779             }
88780             var info = state.fileInfos.get(sourceFile.resolvedPath);
88781             if (!info)
88782                 return ts.Debug.fail();
88783             var prevSignature = info.signature;
88784             var latestSignature;
88785             if (sourceFile.isDeclarationFile) {
88786                 latestSignature = sourceFile.version;
88787                 if (exportedModulesMapCache && latestSignature !== prevSignature) {
88788                     var references = state.referencedMap ? state.referencedMap.get(sourceFile.resolvedPath) : undefined;
88789                     exportedModulesMapCache.set(sourceFile.resolvedPath, references || false);
88790                 }
88791             }
88792             else {
88793                 var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile, true, cancellationToken, undefined, true);
88794                 var firstDts_1 = emitOutput_1.outputFiles &&
88795                     programOfThisState.getCompilerOptions().declarationMap ?
88796                     emitOutput_1.outputFiles.length > 1 ? emitOutput_1.outputFiles[1] : undefined :
88797                     emitOutput_1.outputFiles.length > 0 ? emitOutput_1.outputFiles[0] : undefined;
88798                 if (firstDts_1) {
88799                     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; })); });
88800                     latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
88801                     if (exportedModulesMapCache && latestSignature !== prevSignature) {
88802                         updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
88803                     }
88804                 }
88805                 else {
88806                     latestSignature = prevSignature;
88807                 }
88808             }
88809             cacheToUpdateSignature.set(sourceFile.resolvedPath, latestSignature);
88810             return !prevSignature || latestSignature !== prevSignature;
88811         }
88812         BuilderState.updateShapeSignature = updateShapeSignature;
88813         function updateExportedModules(sourceFile, exportedModulesFromDeclarationEmit, exportedModulesMapCache) {
88814             if (!exportedModulesFromDeclarationEmit) {
88815                 exportedModulesMapCache.set(sourceFile.resolvedPath, false);
88816                 return;
88817             }
88818             var exportedModules;
88819             exportedModulesFromDeclarationEmit.forEach(function (symbol) { return addExportedModule(getReferencedFileFromImportedModuleSymbol(symbol)); });
88820             exportedModulesMapCache.set(sourceFile.resolvedPath, exportedModules || false);
88821             function addExportedModule(exportedModulePath) {
88822                 if (exportedModulePath) {
88823                     if (!exportedModules) {
88824                         exportedModules = new ts.Set();
88825                     }
88826                     exportedModules.add(exportedModulePath);
88827                 }
88828             }
88829         }
88830         function updateExportedFilesMapFromCache(state, exportedModulesMapCache) {
88831             if (exportedModulesMapCache) {
88832                 ts.Debug.assert(!!state.exportedModulesMap);
88833                 exportedModulesMapCache.forEach(function (exportedModules, path) {
88834                     if (exportedModules) {
88835                         state.exportedModulesMap.set(path, exportedModules);
88836                     }
88837                     else {
88838                         state.exportedModulesMap.delete(path);
88839                     }
88840                 });
88841             }
88842         }
88843         BuilderState.updateExportedFilesMapFromCache = updateExportedFilesMapFromCache;
88844         function getAllDependencies(state, programOfThisState, sourceFile) {
88845             var compilerOptions = programOfThisState.getCompilerOptions();
88846             if (ts.outFile(compilerOptions)) {
88847                 return getAllFileNames(state, programOfThisState);
88848             }
88849             if (!state.referencedMap || isFileAffectingGlobalScope(sourceFile)) {
88850                 return getAllFileNames(state, programOfThisState);
88851             }
88852             var seenMap = new ts.Set();
88853             var queue = [sourceFile.resolvedPath];
88854             while (queue.length) {
88855                 var path = queue.pop();
88856                 if (!seenMap.has(path)) {
88857                     seenMap.add(path);
88858                     var references = state.referencedMap.get(path);
88859                     if (references) {
88860                         var iterator = references.keys();
88861                         for (var iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) {
88862                             queue.push(iterResult.value);
88863                         }
88864                     }
88865                 }
88866             }
88867             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; }));
88868         }
88869         BuilderState.getAllDependencies = getAllDependencies;
88870         function getAllFileNames(state, programOfThisState) {
88871             if (!state.allFileNames) {
88872                 var sourceFiles = programOfThisState.getSourceFiles();
88873                 state.allFileNames = sourceFiles === ts.emptyArray ? ts.emptyArray : sourceFiles.map(function (file) { return file.fileName; });
88874             }
88875             return state.allFileNames;
88876         }
88877         function getReferencedByPaths(state, referencedFilePath) {
88878             return ts.arrayFrom(ts.mapDefinedIterator(state.referencedMap.entries(), function (_a) {
88879                 var filePath = _a[0], referencesInFile = _a[1];
88880                 return referencesInFile.has(referencedFilePath) ? filePath : undefined;
88881             }));
88882         }
88883         BuilderState.getReferencedByPaths = getReferencedByPaths;
88884         function containsOnlyAmbientModules(sourceFile) {
88885             for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
88886                 var statement = _a[_i];
88887                 if (!ts.isModuleWithStringLiteralName(statement)) {
88888                     return false;
88889                 }
88890             }
88891             return true;
88892         }
88893         function containsGlobalScopeAugmentation(sourceFile) {
88894             return ts.some(sourceFile.moduleAugmentations, function (augmentation) { return ts.isGlobalScopeAugmentation(augmentation.parent); });
88895         }
88896         function isFileAffectingGlobalScope(sourceFile) {
88897             return containsGlobalScopeAugmentation(sourceFile) ||
88898                 !ts.isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile);
88899         }
88900         function getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, firstSourceFile) {
88901             if (state.allFilesExcludingDefaultLibraryFile) {
88902                 return state.allFilesExcludingDefaultLibraryFile;
88903             }
88904             var result;
88905             if (firstSourceFile)
88906                 addSourceFile(firstSourceFile);
88907             for (var _i = 0, _a = programOfThisState.getSourceFiles(); _i < _a.length; _i++) {
88908                 var sourceFile = _a[_i];
88909                 if (sourceFile !== firstSourceFile) {
88910                     addSourceFile(sourceFile);
88911                 }
88912             }
88913             state.allFilesExcludingDefaultLibraryFile = result || ts.emptyArray;
88914             return state.allFilesExcludingDefaultLibraryFile;
88915             function addSourceFile(sourceFile) {
88916                 if (!programOfThisState.isSourceFileDefaultLibrary(sourceFile)) {
88917                     (result || (result = [])).push(sourceFile);
88918                 }
88919             }
88920         }
88921         BuilderState.getAllFilesExcludingDefaultLibraryFile = getAllFilesExcludingDefaultLibraryFile;
88922         function getFilesAffectedByUpdatedShapeWhenNonModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape) {
88923             var compilerOptions = programOfThisState.getCompilerOptions();
88924             if (compilerOptions && ts.outFile(compilerOptions)) {
88925                 return [sourceFileWithUpdatedShape];
88926             }
88927             return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
88928         }
88929         function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) {
88930             if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
88931                 return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
88932             }
88933             var compilerOptions = programOfThisState.getCompilerOptions();
88934             if (compilerOptions && (compilerOptions.isolatedModules || ts.outFile(compilerOptions))) {
88935                 return [sourceFileWithUpdatedShape];
88936             }
88937             var seenFileNamesMap = new ts.Map();
88938             seenFileNamesMap.set(sourceFileWithUpdatedShape.resolvedPath, sourceFileWithUpdatedShape);
88939             var queue = getReferencedByPaths(state, sourceFileWithUpdatedShape.resolvedPath);
88940             while (queue.length > 0) {
88941                 var currentPath = queue.pop();
88942                 if (!seenFileNamesMap.has(currentPath)) {
88943                     var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
88944                     seenFileNamesMap.set(currentPath, currentSourceFile);
88945                     if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache)) {
88946                         queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
88947                     }
88948                 }
88949             }
88950             return ts.arrayFrom(ts.mapDefinedIterator(seenFileNamesMap.values(), function (value) { return value; }));
88951         }
88952     })(BuilderState = ts.BuilderState || (ts.BuilderState = {}));
88953 })(ts || (ts = {}));
88954 var ts;
88955 (function (ts) {
88956     function hasSameKeys(map1, map2) {
88957         return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); });
88958     }
88959     function createBuilderProgramState(newProgram, getCanonicalFileName, oldState) {
88960         var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState);
88961         state.program = newProgram;
88962         var compilerOptions = newProgram.getCompilerOptions();
88963         state.compilerOptions = compilerOptions;
88964         if (!ts.outFile(compilerOptions)) {
88965             state.semanticDiagnosticsPerFile = new ts.Map();
88966         }
88967         state.changedFilesSet = new ts.Set();
88968         var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState);
88969         var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
88970         var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
88971             !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
88972         if (useOldState) {
88973             if (!oldState.currentChangedFilePath) {
88974                 var affectedSignatures = oldState.currentAffectedFilesSignatures;
88975                 ts.Debug.assert(!oldState.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated");
88976             }
88977             var changedFilesSet = oldState.changedFilesSet;
88978             if (canCopySemanticDiagnostics) {
88979                 ts.Debug.assert(!changedFilesSet || !ts.forEachKey(changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files");
88980             }
88981             changedFilesSet === null || changedFilesSet === void 0 ? void 0 : changedFilesSet.forEach(function (value) { return state.changedFilesSet.add(value); });
88982             if (!ts.outFile(compilerOptions) && oldState.affectedFilesPendingEmit) {
88983                 state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice();
88984                 state.affectedFilesPendingEmitKind = oldState.affectedFilesPendingEmitKind && new ts.Map(oldState.affectedFilesPendingEmitKind);
88985                 state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex;
88986                 state.seenAffectedFiles = new ts.Set();
88987             }
88988         }
88989         var referencedMap = state.referencedMap;
88990         var oldReferencedMap = useOldState ? oldState.referencedMap : undefined;
88991         var copyDeclarationFileDiagnostics = canCopySemanticDiagnostics && !compilerOptions.skipLibCheck === !oldCompilerOptions.skipLibCheck;
88992         var copyLibFileDiagnostics = copyDeclarationFileDiagnostics && !compilerOptions.skipDefaultLibCheck === !oldCompilerOptions.skipDefaultLibCheck;
88993         state.fileInfos.forEach(function (info, sourceFilePath) {
88994             var oldInfo;
88995             var newReferences;
88996             if (!useOldState ||
88997                 !(oldInfo = oldState.fileInfos.get(sourceFilePath)) ||
88998                 oldInfo.version !== info.version ||
88999                 !hasSameKeys(newReferences = referencedMap && referencedMap.get(sourceFilePath), oldReferencedMap && oldReferencedMap.get(sourceFilePath)) ||
89000                 newReferences && ts.forEachKey(newReferences, function (path) { return !state.fileInfos.has(path) && oldState.fileInfos.has(path); })) {
89001                 state.changedFilesSet.add(sourceFilePath);
89002             }
89003             else if (canCopySemanticDiagnostics) {
89004                 var sourceFile = newProgram.getSourceFileByPath(sourceFilePath);
89005                 if (sourceFile.isDeclarationFile && !copyDeclarationFileDiagnostics) {
89006                     return;
89007                 }
89008                 if (sourceFile.hasNoDefaultLib && !copyLibFileDiagnostics) {
89009                     return;
89010                 }
89011                 var diagnostics = oldState.semanticDiagnosticsPerFile.get(sourceFilePath);
89012                 if (diagnostics) {
89013                     state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) : diagnostics);
89014                     if (!state.semanticDiagnosticsFromOldState) {
89015                         state.semanticDiagnosticsFromOldState = new ts.Set();
89016                     }
89017                     state.semanticDiagnosticsFromOldState.add(sourceFilePath);
89018                 }
89019             }
89020         });
89021         if (useOldState && ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) { return info.affectsGlobalScope && !state.fileInfos.has(sourceFilePath); })) {
89022             ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, newProgram, undefined)
89023                 .forEach(function (file) { return state.changedFilesSet.add(file.resolvedPath); });
89024         }
89025         else if (oldCompilerOptions && !ts.outFile(compilerOptions) && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
89026             newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1); });
89027             ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
89028             state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
89029         }
89030         state.buildInfoEmitPending = !!state.changedFilesSet.size;
89031         return state;
89032     }
89033     function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
89034         if (!diagnostics.length)
89035             return ts.emptyArray;
89036         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory()));
89037         return diagnostics.map(function (diagnostic) {
89038             var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath);
89039             result.reportsUnnecessary = diagnostic.reportsUnnecessary;
89040             result.reportsDeprecated = diagnostic.reportDeprecated;
89041             result.source = diagnostic.source;
89042             result.skippedOn = diagnostic.skippedOn;
89043             var relatedInformation = diagnostic.relatedInformation;
89044             result.relatedInformation = relatedInformation ?
89045                 relatedInformation.length ?
89046                     relatedInformation.map(function (r) { return convertToDiagnosticRelatedInformation(r, newProgram, toPath); }) :
89047                     [] :
89048                 undefined;
89049             return result;
89050         });
89051         function toPath(path) {
89052             return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
89053         }
89054     }
89055     function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) {
89056         var file = diagnostic.file;
89057         return __assign(__assign({}, diagnostic), { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined });
89058     }
89059     function releaseCache(state) {
89060         ts.BuilderState.releaseCache(state);
89061         state.program = undefined;
89062     }
89063     function cloneBuilderProgramState(state) {
89064         var newState = ts.BuilderState.clone(state);
89065         newState.semanticDiagnosticsPerFile = state.semanticDiagnosticsPerFile && new ts.Map(state.semanticDiagnosticsPerFile);
89066         newState.changedFilesSet = new ts.Set(state.changedFilesSet);
89067         newState.affectedFiles = state.affectedFiles;
89068         newState.affectedFilesIndex = state.affectedFilesIndex;
89069         newState.currentChangedFilePath = state.currentChangedFilePath;
89070         newState.currentAffectedFilesSignatures = state.currentAffectedFilesSignatures && new ts.Map(state.currentAffectedFilesSignatures);
89071         newState.currentAffectedFilesExportedModulesMap = state.currentAffectedFilesExportedModulesMap && new ts.Map(state.currentAffectedFilesExportedModulesMap);
89072         newState.seenAffectedFiles = state.seenAffectedFiles && new ts.Set(state.seenAffectedFiles);
89073         newState.cleanedDiagnosticsOfLibFiles = state.cleanedDiagnosticsOfLibFiles;
89074         newState.semanticDiagnosticsFromOldState = state.semanticDiagnosticsFromOldState && new ts.Set(state.semanticDiagnosticsFromOldState);
89075         newState.program = state.program;
89076         newState.compilerOptions = state.compilerOptions;
89077         newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
89078         newState.affectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
89079         newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
89080         newState.seenEmittedFiles = state.seenEmittedFiles && new ts.Map(state.seenEmittedFiles);
89081         newState.programEmitComplete = state.programEmitComplete;
89082         return newState;
89083     }
89084     function assertSourceFileOkWithoutNextAffectedCall(state, sourceFile) {
89085         ts.Debug.assert(!sourceFile || !state.affectedFiles || state.affectedFiles[state.affectedFilesIndex - 1] !== sourceFile || !state.semanticDiagnosticsPerFile.has(sourceFile.resolvedPath));
89086     }
89087     function getNextAffectedFile(state, cancellationToken, computeHash) {
89088         while (true) {
89089             var affectedFiles = state.affectedFiles;
89090             if (affectedFiles) {
89091                 var seenAffectedFiles = state.seenAffectedFiles;
89092                 var affectedFilesIndex = state.affectedFilesIndex;
89093                 while (affectedFilesIndex < affectedFiles.length) {
89094                     var affectedFile = affectedFiles[affectedFilesIndex];
89095                     if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
89096                         state.affectedFilesIndex = affectedFilesIndex;
89097                         handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash);
89098                         return affectedFile;
89099                     }
89100                     affectedFilesIndex++;
89101                 }
89102                 state.changedFilesSet.delete(state.currentChangedFilePath);
89103                 state.currentChangedFilePath = undefined;
89104                 ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures);
89105                 state.currentAffectedFilesSignatures.clear();
89106                 ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
89107                 state.affectedFiles = undefined;
89108             }
89109             var nextKey = state.changedFilesSet.keys().next();
89110             if (nextKey.done) {
89111                 return undefined;
89112             }
89113             var program = ts.Debug.checkDefined(state.program);
89114             var compilerOptions = program.getCompilerOptions();
89115             if (ts.outFile(compilerOptions)) {
89116                 ts.Debug.assert(!state.semanticDiagnosticsPerFile);
89117                 return program;
89118             }
89119             if (!state.currentAffectedFilesSignatures)
89120                 state.currentAffectedFilesSignatures = new ts.Map();
89121             if (state.exportedModulesMap) {
89122                 if (!state.currentAffectedFilesExportedModulesMap)
89123                     state.currentAffectedFilesExportedModulesMap = new ts.Map();
89124             }
89125             state.affectedFiles = ts.BuilderState.getFilesAffectedBy(state, program, nextKey.value, cancellationToken, computeHash, state.currentAffectedFilesSignatures, state.currentAffectedFilesExportedModulesMap);
89126             state.currentChangedFilePath = nextKey.value;
89127             state.affectedFilesIndex = 0;
89128             if (!state.seenAffectedFiles)
89129                 state.seenAffectedFiles = new ts.Set();
89130         }
89131     }
89132     function getNextAffectedFilePendingEmit(state) {
89133         var affectedFilesPendingEmit = state.affectedFilesPendingEmit;
89134         if (affectedFilesPendingEmit) {
89135             var seenEmittedFiles = (state.seenEmittedFiles || (state.seenEmittedFiles = new ts.Map()));
89136             for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) {
89137                 var affectedFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]);
89138                 if (affectedFile) {
89139                     var seenKind = seenEmittedFiles.get(affectedFile.resolvedPath);
89140                     var emitKind = ts.Debug.checkDefined(ts.Debug.checkDefined(state.affectedFilesPendingEmitKind).get(affectedFile.resolvedPath));
89141                     if (seenKind === undefined || seenKind < emitKind) {
89142                         state.affectedFilesPendingEmitIndex = i;
89143                         return { affectedFile: affectedFile, emitKind: emitKind };
89144                     }
89145                 }
89146             }
89147             state.affectedFilesPendingEmit = undefined;
89148             state.affectedFilesPendingEmitKind = undefined;
89149             state.affectedFilesPendingEmitIndex = undefined;
89150         }
89151         return undefined;
89152     }
89153     function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash) {
89154         removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
89155         if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
89156             if (!state.cleanedDiagnosticsOfLibFiles) {
89157                 state.cleanedDiagnosticsOfLibFiles = true;
89158                 var program_1 = ts.Debug.checkDefined(state.program);
89159                 var options_2 = program_1.getCompilerOptions();
89160                 ts.forEach(program_1.getSourceFiles(), function (f) {
89161                     return program_1.isSourceFileDefaultLibrary(f) &&
89162                         !ts.skipTypeChecking(f, options_2, program_1) &&
89163                         removeSemanticDiagnosticsOf(state, f.resolvedPath);
89164                 });
89165             }
89166             return;
89167         }
89168         if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
89169             forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); });
89170         }
89171     }
89172     function handleDtsMayChangeOf(state, path, cancellationToken, computeHash) {
89173         removeSemanticDiagnosticsOf(state, path);
89174         if (!state.changedFilesSet.has(path)) {
89175             var program = ts.Debug.checkDefined(state.program);
89176             var sourceFile = program.getSourceFileByPath(path);
89177             if (sourceFile) {
89178                 ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
89179                 if (ts.getEmitDeclarations(state.compilerOptions)) {
89180                     addToAffectedFilesPendingEmit(state, path, 0);
89181                 }
89182             }
89183         }
89184         return false;
89185     }
89186     function removeSemanticDiagnosticsOf(state, path) {
89187         if (!state.semanticDiagnosticsFromOldState) {
89188             return true;
89189         }
89190         state.semanticDiagnosticsFromOldState.delete(path);
89191         state.semanticDiagnosticsPerFile.delete(path);
89192         return !state.semanticDiagnosticsFromOldState.size;
89193     }
89194     function isChangedSignature(state, path) {
89195         var newSignature = ts.Debug.checkDefined(state.currentAffectedFilesSignatures).get(path);
89196         var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
89197         return newSignature !== oldSignature;
89198     }
89199     function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) {
89200         if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) {
89201             return;
89202         }
89203         if (!isChangedSignature(state, affectedFile.resolvedPath))
89204             return;
89205         if (state.compilerOptions.isolatedModules) {
89206             var seenFileNamesMap = new ts.Map();
89207             seenFileNamesMap.set(affectedFile.resolvedPath, true);
89208             var queue = ts.BuilderState.getReferencedByPaths(state, affectedFile.resolvedPath);
89209             while (queue.length > 0) {
89210                 var currentPath = queue.pop();
89211                 if (!seenFileNamesMap.has(currentPath)) {
89212                     seenFileNamesMap.set(currentPath, true);
89213                     var result = fn(state, currentPath);
89214                     if (result && isChangedSignature(state, currentPath)) {
89215                         var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
89216                         queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
89217                     }
89218                 }
89219             }
89220         }
89221         ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
89222         var seenFileAndExportsOfFile = new ts.Set();
89223         if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) {
89224             return exportedModules &&
89225                 exportedModules.has(affectedFile.resolvedPath) &&
89226                 forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
89227         })) {
89228             return;
89229         }
89230         ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) {
89231             return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) &&
89232                 exportedModules.has(affectedFile.resolvedPath) &&
89233                 forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
89234         });
89235     }
89236     function forEachFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile, fn) {
89237         return ts.forEachEntry(state.referencedMap, function (referencesInFile, filePath) {
89238             return referencesInFile.has(referencedPath) && forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn);
89239         });
89240     }
89241     function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) {
89242         if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) {
89243             return false;
89244         }
89245         if (fn(state, filePath)) {
89246             return true;
89247         }
89248         ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
89249         if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) {
89250             return exportedModules &&
89251                 exportedModules.has(filePath) &&
89252                 forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
89253         })) {
89254             return true;
89255         }
89256         if (ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) {
89257             return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) &&
89258                 exportedModules.has(filePath) &&
89259                 forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
89260         })) {
89261             return true;
89262         }
89263         return !!ts.forEachEntry(state.referencedMap, function (referencesInFile, referencingFilePath) {
89264             return referencesInFile.has(filePath) &&
89265                 !seenFileAndExportsOfFile.has(referencingFilePath) &&
89266                 fn(state, referencingFilePath);
89267         });
89268     }
89269     function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) {
89270         if (isBuildInfoEmit) {
89271             state.buildInfoEmitPending = false;
89272         }
89273         else if (affected === state.program) {
89274             state.changedFilesSet.clear();
89275             state.programEmitComplete = true;
89276         }
89277         else {
89278             state.seenAffectedFiles.add(affected.resolvedPath);
89279             if (emitKind !== undefined) {
89280                 (state.seenEmittedFiles || (state.seenEmittedFiles = new ts.Map())).set(affected.resolvedPath, emitKind);
89281             }
89282             if (isPendingEmit) {
89283                 state.affectedFilesPendingEmitIndex++;
89284                 state.buildInfoEmitPending = true;
89285             }
89286             else {
89287                 state.affectedFilesIndex++;
89288             }
89289         }
89290     }
89291     function toAffectedFileResult(state, result, affected) {
89292         doneWithAffectedFile(state, affected);
89293         return { result: result, affected: affected };
89294     }
89295     function toAffectedFileEmitResult(state, result, affected, emitKind, isPendingEmit, isBuildInfoEmit) {
89296         doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit);
89297         return { result: result, affected: affected };
89298     }
89299     function getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken) {
89300         return ts.concatenate(getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken), ts.Debug.checkDefined(state.program).getProgramDiagnostics(sourceFile));
89301     }
89302     function getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken) {
89303         var path = sourceFile.resolvedPath;
89304         if (state.semanticDiagnosticsPerFile) {
89305             var cachedDiagnostics = state.semanticDiagnosticsPerFile.get(path);
89306             if (cachedDiagnostics) {
89307                 return ts.filterSemanticDiagnotics(cachedDiagnostics, state.compilerOptions);
89308             }
89309         }
89310         var diagnostics = ts.Debug.checkDefined(state.program).getBindAndCheckDiagnostics(sourceFile, cancellationToken);
89311         if (state.semanticDiagnosticsPerFile) {
89312             state.semanticDiagnosticsPerFile.set(path, diagnostics);
89313         }
89314         return ts.filterSemanticDiagnotics(diagnostics, state.compilerOptions);
89315     }
89316     function getProgramBuildInfo(state, getCanonicalFileName) {
89317         if (ts.outFile(state.compilerOptions))
89318             return undefined;
89319         var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
89320         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
89321         var fileInfos = {};
89322         state.fileInfos.forEach(function (value, key) {
89323             var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
89324             fileInfos[relativeToBuildInfo(key)] = signature === undefined ? value : { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope };
89325         });
89326         var result = {
89327             fileInfos: fileInfos,
89328             options: convertToReusableCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath)
89329         };
89330         if (state.referencedMap) {
89331             var referencedMap = {};
89332             for (var _i = 0, _a = ts.arrayFrom(state.referencedMap.keys()).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
89333                 var key = _a[_i];
89334                 referencedMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.referencedMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive);
89335             }
89336             result.referencedMap = referencedMap;
89337         }
89338         if (state.exportedModulesMap) {
89339             var exportedModulesMap = {};
89340             for (var _b = 0, _c = ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive); _b < _c.length; _b++) {
89341                 var key = _c[_b];
89342                 var newValue = state.currentAffectedFilesExportedModulesMap && state.currentAffectedFilesExportedModulesMap.get(key);
89343                 if (newValue === undefined)
89344                     exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.exportedModulesMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive);
89345                 else if (newValue)
89346                     exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(newValue.keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive);
89347             }
89348             result.exportedModulesMap = exportedModulesMap;
89349         }
89350         if (state.semanticDiagnosticsPerFile) {
89351             var semanticDiagnosticsPerFile = [];
89352             for (var _d = 0, _e = ts.arrayFrom(state.semanticDiagnosticsPerFile.keys()).sort(ts.compareStringsCaseSensitive); _d < _e.length; _d++) {
89353                 var key = _e[_d];
89354                 var value = state.semanticDiagnosticsPerFile.get(key);
89355                 semanticDiagnosticsPerFile.push(value.length ?
89356                     [
89357                         relativeToBuildInfo(key),
89358                         state.hasReusableDiagnostic ?
89359                             value :
89360                             convertToReusableDiagnostics(value, relativeToBuildInfo)
89361                     ] :
89362                     relativeToBuildInfo(key));
89363             }
89364             result.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile;
89365         }
89366         if (state.affectedFilesPendingEmit) {
89367             var affectedFilesPendingEmit = [];
89368             var seenFiles = new ts.Set();
89369             for (var _f = 0, _g = state.affectedFilesPendingEmit.slice(state.affectedFilesPendingEmitIndex).sort(ts.compareStringsCaseSensitive); _f < _g.length; _f++) {
89370                 var path = _g[_f];
89371                 if (ts.tryAddToSet(seenFiles, path)) {
89372                     affectedFilesPendingEmit.push([relativeToBuildInfo(path), state.affectedFilesPendingEmitKind.get(path)]);
89373                 }
89374             }
89375             result.affectedFilesPendingEmit = affectedFilesPendingEmit;
89376         }
89377         return result;
89378         function relativeToBuildInfoEnsuringAbsolutePath(path) {
89379             return relativeToBuildInfo(ts.getNormalizedAbsolutePath(path, currentDirectory));
89380         }
89381         function relativeToBuildInfo(path) {
89382             return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, getCanonicalFileName));
89383         }
89384     }
89385     function convertToReusableCompilerOptions(options, relativeToBuildInfo) {
89386         var result = {};
89387         var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
89388         for (var name in options) {
89389             if (ts.hasProperty(options, name)) {
89390                 result[name] = convertToReusableCompilerOptionValue(optionsNameMap.get(name.toLowerCase()), options[name], relativeToBuildInfo);
89391             }
89392         }
89393         if (result.configFilePath) {
89394             result.configFilePath = relativeToBuildInfo(result.configFilePath);
89395         }
89396         return result;
89397     }
89398     function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) {
89399         if (option) {
89400             if (option.type === "list") {
89401                 var values = value;
89402                 if (option.element.isFilePath && values.length) {
89403                     return values.map(relativeToBuildInfo);
89404                 }
89405             }
89406             else if (option.isFilePath) {
89407                 return relativeToBuildInfo(value);
89408             }
89409         }
89410         return value;
89411     }
89412     function convertToReusableDiagnostics(diagnostics, relativeToBuildInfo) {
89413         ts.Debug.assert(!!diagnostics.length);
89414         return diagnostics.map(function (diagnostic) {
89415             var result = convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo);
89416             result.reportsUnnecessary = diagnostic.reportsUnnecessary;
89417             result.reportDeprecated = diagnostic.reportsDeprecated;
89418             result.source = diagnostic.source;
89419             result.skippedOn = diagnostic.skippedOn;
89420             var relatedInformation = diagnostic.relatedInformation;
89421             result.relatedInformation = relatedInformation ?
89422                 relatedInformation.length ?
89423                     relatedInformation.map(function (r) { return convertToReusableDiagnosticRelatedInformation(r, relativeToBuildInfo); }) :
89424                     [] :
89425                 undefined;
89426             return result;
89427         });
89428     }
89429     function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo) {
89430         var file = diagnostic.file;
89431         return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.resolvedPath) : undefined });
89432     }
89433     var BuilderProgramKind;
89434     (function (BuilderProgramKind) {
89435         BuilderProgramKind[BuilderProgramKind["SemanticDiagnosticsBuilderProgram"] = 0] = "SemanticDiagnosticsBuilderProgram";
89436         BuilderProgramKind[BuilderProgramKind["EmitAndSemanticDiagnosticsBuilderProgram"] = 1] = "EmitAndSemanticDiagnosticsBuilderProgram";
89437     })(BuilderProgramKind = ts.BuilderProgramKind || (ts.BuilderProgramKind = {}));
89438     function getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
89439         var host;
89440         var newProgram;
89441         var oldProgram;
89442         if (newProgramOrRootNames === undefined) {
89443             ts.Debug.assert(hostOrOptions === undefined);
89444             host = oldProgramOrHost;
89445             oldProgram = configFileParsingDiagnosticsOrOldProgram;
89446             ts.Debug.assert(!!oldProgram);
89447             newProgram = oldProgram.getProgram();
89448         }
89449         else if (ts.isArray(newProgramOrRootNames)) {
89450             oldProgram = configFileParsingDiagnosticsOrOldProgram;
89451             newProgram = ts.createProgram({
89452                 rootNames: newProgramOrRootNames,
89453                 options: hostOrOptions,
89454                 host: oldProgramOrHost,
89455                 oldProgram: oldProgram && oldProgram.getProgramOrUndefined(),
89456                 configFileParsingDiagnostics: configFileParsingDiagnostics,
89457                 projectReferences: projectReferences
89458             });
89459             host = oldProgramOrHost;
89460         }
89461         else {
89462             newProgram = newProgramOrRootNames;
89463             host = hostOrOptions;
89464             oldProgram = oldProgramOrHost;
89465             configFileParsingDiagnostics = configFileParsingDiagnosticsOrOldProgram;
89466         }
89467         return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray };
89468     }
89469     ts.getBuilderCreationParameters = getBuilderCreationParameters;
89470     function createBuilderProgram(kind, _a) {
89471         var newProgram = _a.newProgram, host = _a.host, oldProgram = _a.oldProgram, configFileParsingDiagnostics = _a.configFileParsingDiagnostics;
89472         var oldState = oldProgram && oldProgram.getState();
89473         if (oldState && newProgram === oldState.program && configFileParsingDiagnostics === newProgram.getConfigFileParsingDiagnostics()) {
89474             newProgram = undefined;
89475             oldState = undefined;
89476             return oldProgram;
89477         }
89478         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
89479         var computeHash = ts.maybeBind(host, host.createHash);
89480         var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState);
89481         var backupState;
89482         newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
89483         newProgram = undefined;
89484         oldProgram = undefined;
89485         oldState = undefined;
89486         var builderProgram = createRedirectedBuilderProgram(state, configFileParsingDiagnostics);
89487         builderProgram.getState = function () { return state; };
89488         builderProgram.backupState = function () {
89489             ts.Debug.assert(backupState === undefined);
89490             backupState = cloneBuilderProgramState(state);
89491         };
89492         builderProgram.restoreState = function () {
89493             state = ts.Debug.checkDefined(backupState);
89494             backupState = undefined;
89495         };
89496         builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); };
89497         builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
89498         builderProgram.emit = emit;
89499         builderProgram.releaseProgram = function () {
89500             releaseCache(state);
89501             backupState = undefined;
89502         };
89503         if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) {
89504             builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
89505         }
89506         else if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
89507             builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
89508             builderProgram.emitNextAffectedFile = emitNextAffectedFile;
89509             builderProgram.emitBuildInfo = emitBuildInfo;
89510         }
89511         else {
89512             ts.notImplemented();
89513         }
89514         return builderProgram;
89515         function emitBuildInfo(writeFile, cancellationToken) {
89516             if (state.buildInfoEmitPending) {
89517                 var result = ts.Debug.checkDefined(state.program).emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken);
89518                 state.buildInfoEmitPending = false;
89519                 return result;
89520             }
89521             return ts.emitSkippedWithNoDiagnostics;
89522         }
89523         function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
89524             var affected = getNextAffectedFile(state, cancellationToken, computeHash);
89525             var emitKind = 1;
89526             var isPendingEmitFile = false;
89527             if (!affected) {
89528                 if (!ts.outFile(state.compilerOptions)) {
89529                     var pendingAffectedFile = getNextAffectedFilePendingEmit(state);
89530                     if (!pendingAffectedFile) {
89531                         if (!state.buildInfoEmitPending) {
89532                             return undefined;
89533                         }
89534                         var affected_1 = ts.Debug.checkDefined(state.program);
89535                         return toAffectedFileEmitResult(state, affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1, false, true);
89536                     }
89537                     (affected = pendingAffectedFile.affectedFile, emitKind = pendingAffectedFile.emitKind);
89538                     isPendingEmitFile = true;
89539                 }
89540                 else {
89541                     var program = ts.Debug.checkDefined(state.program);
89542                     if (state.programEmitComplete)
89543                         return undefined;
89544                     affected = program;
89545                 }
89546             }
89547             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);
89548         }
89549         function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
89550             var restorePendingEmitOnHandlingNoEmitSuccess = false;
89551             var savedAffectedFilesPendingEmit;
89552             var savedAffectedFilesPendingEmitKind;
89553             var savedAffectedFilesPendingEmitIndex;
89554             if (kind !== BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram &&
89555                 !targetSourceFile &&
89556                 !ts.outFile(state.compilerOptions) &&
89557                 !state.compilerOptions.noEmit &&
89558                 state.compilerOptions.noEmitOnError) {
89559                 restorePendingEmitOnHandlingNoEmitSuccess = true;
89560                 savedAffectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
89561                 savedAffectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
89562                 savedAffectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
89563             }
89564             if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
89565                 assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile);
89566             }
89567             var result = ts.handleNoEmitOptions(builderProgram, targetSourceFile, writeFile, cancellationToken);
89568             if (result)
89569                 return result;
89570             if (restorePendingEmitOnHandlingNoEmitSuccess) {
89571                 state.affectedFilesPendingEmit = savedAffectedFilesPendingEmit;
89572                 state.affectedFilesPendingEmitKind = savedAffectedFilesPendingEmitKind;
89573                 state.affectedFilesPendingEmitIndex = savedAffectedFilesPendingEmitIndex;
89574             }
89575             if (!targetSourceFile && kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
89576                 var sourceMaps = [];
89577                 var emitSkipped = false;
89578                 var diagnostics = void 0;
89579                 var emittedFiles = [];
89580                 var affectedEmitResult = void 0;
89581                 while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
89582                     emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
89583                     diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics);
89584                     emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
89585                     sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps);
89586                 }
89587                 return {
89588                     emitSkipped: emitSkipped,
89589                     diagnostics: diagnostics || ts.emptyArray,
89590                     emittedFiles: emittedFiles,
89591                     sourceMaps: sourceMaps
89592                 };
89593             }
89594             return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
89595         }
89596         function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
89597             while (true) {
89598                 var affected = getNextAffectedFile(state, cancellationToken, computeHash);
89599                 if (!affected) {
89600                     return undefined;
89601                 }
89602                 else if (affected === state.program) {
89603                     return toAffectedFileResult(state, state.program.getSemanticDiagnostics(undefined, cancellationToken), affected);
89604                 }
89605                 if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram || state.compilerOptions.noEmit || state.compilerOptions.noEmitOnError) {
89606                     addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1);
89607                 }
89608                 if (ignoreSourceFile && ignoreSourceFile(affected)) {
89609                     doneWithAffectedFile(state, affected);
89610                     continue;
89611                 }
89612                 return toAffectedFileResult(state, getSemanticDiagnosticsOfFile(state, affected, cancellationToken), affected);
89613             }
89614         }
89615         function getSemanticDiagnostics(sourceFile, cancellationToken) {
89616             assertSourceFileOkWithoutNextAffectedCall(state, sourceFile);
89617             var compilerOptions = ts.Debug.checkDefined(state.program).getCompilerOptions();
89618             if (ts.outFile(compilerOptions)) {
89619                 ts.Debug.assert(!state.semanticDiagnosticsPerFile);
89620                 return ts.Debug.checkDefined(state.program).getSemanticDiagnostics(sourceFile, cancellationToken);
89621             }
89622             if (sourceFile) {
89623                 return getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken);
89624             }
89625             while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) {
89626             }
89627             var diagnostics;
89628             for (var _i = 0, _a = ts.Debug.checkDefined(state.program).getSourceFiles(); _i < _a.length; _i++) {
89629                 var sourceFile_1 = _a[_i];
89630                 diagnostics = ts.addRange(diagnostics, getSemanticDiagnosticsOfFile(state, sourceFile_1, cancellationToken));
89631             }
89632             return diagnostics || ts.emptyArray;
89633         }
89634     }
89635     ts.createBuilderProgram = createBuilderProgram;
89636     function addToAffectedFilesPendingEmit(state, affectedFilePendingEmit, kind) {
89637         if (!state.affectedFilesPendingEmit)
89638             state.affectedFilesPendingEmit = [];
89639         if (!state.affectedFilesPendingEmitKind)
89640             state.affectedFilesPendingEmitKind = new ts.Map();
89641         var existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit);
89642         state.affectedFilesPendingEmit.push(affectedFilePendingEmit);
89643         state.affectedFilesPendingEmitKind.set(affectedFilePendingEmit, existingKind || kind);
89644         if (state.affectedFilesPendingEmitIndex === undefined) {
89645             state.affectedFilesPendingEmitIndex = 0;
89646         }
89647     }
89648     function getMapOfReferencedSet(mapLike, toPath) {
89649         if (!mapLike)
89650             return undefined;
89651         var map = new ts.Map();
89652         for (var key in mapLike) {
89653             if (ts.hasProperty(mapLike, key)) {
89654                 map.set(toPath(key), new ts.Set(mapLike[key].map(toPath)));
89655             }
89656         }
89657         return map;
89658     }
89659     function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
89660         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
89661         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
89662         var fileInfos = new ts.Map();
89663         for (var key in program.fileInfos) {
89664             if (ts.hasProperty(program.fileInfos, key)) {
89665                 fileInfos.set(toPath(key), program.fileInfos[key]);
89666             }
89667         }
89668         var state = {
89669             fileInfos: fileInfos,
89670             compilerOptions: ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath),
89671             referencedMap: getMapOfReferencedSet(program.referencedMap, toPath),
89672             exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath),
89673             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]; }),
89674             hasReusableDiagnostic: true,
89675             affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toPath(value[0]); }),
89676             affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toPath(value[0]); }, function (value) { return value[1]; }),
89677             affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
89678         };
89679         return {
89680             getState: function () { return state; },
89681             backupState: ts.noop,
89682             restoreState: ts.noop,
89683             getProgram: ts.notImplemented,
89684             getProgramOrUndefined: ts.returnUndefined,
89685             releaseProgram: ts.noop,
89686             getCompilerOptions: function () { return state.compilerOptions; },
89687             getSourceFile: ts.notImplemented,
89688             getSourceFiles: ts.notImplemented,
89689             getOptionsDiagnostics: ts.notImplemented,
89690             getGlobalDiagnostics: ts.notImplemented,
89691             getConfigFileParsingDiagnostics: ts.notImplemented,
89692             getSyntacticDiagnostics: ts.notImplemented,
89693             getDeclarationDiagnostics: ts.notImplemented,
89694             getSemanticDiagnostics: ts.notImplemented,
89695             emit: ts.notImplemented,
89696             getAllDependencies: ts.notImplemented,
89697             getCurrentDirectory: ts.notImplemented,
89698             emitNextAffectedFile: ts.notImplemented,
89699             getSemanticDiagnosticsOfNextAffectedFile: ts.notImplemented,
89700             emitBuildInfo: ts.notImplemented,
89701             close: ts.noop,
89702         };
89703         function toPath(path) {
89704             return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
89705         }
89706         function toAbsolutePath(path) {
89707             return ts.getNormalizedAbsolutePath(path, buildInfoDirectory);
89708         }
89709     }
89710     ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo;
89711     function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) {
89712         return {
89713             getState: ts.notImplemented,
89714             backupState: ts.noop,
89715             restoreState: ts.noop,
89716             getProgram: getProgram,
89717             getProgramOrUndefined: function () { return state.program; },
89718             releaseProgram: function () { return state.program = undefined; },
89719             getCompilerOptions: function () { return state.compilerOptions; },
89720             getSourceFile: function (fileName) { return getProgram().getSourceFile(fileName); },
89721             getSourceFiles: function () { return getProgram().getSourceFiles(); },
89722             getOptionsDiagnostics: function (cancellationToken) { return getProgram().getOptionsDiagnostics(cancellationToken); },
89723             getGlobalDiagnostics: function (cancellationToken) { return getProgram().getGlobalDiagnostics(cancellationToken); },
89724             getConfigFileParsingDiagnostics: function () { return configFileParsingDiagnostics; },
89725             getSyntacticDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getSyntacticDiagnostics(sourceFile, cancellationToken); },
89726             getDeclarationDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getDeclarationDiagnostics(sourceFile, cancellationToken); },
89727             getSemanticDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getSemanticDiagnostics(sourceFile, cancellationToken); },
89728             emit: function (sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers) { return getProgram().emit(sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers); },
89729             emitBuildInfo: function (writeFile, cancellationToken) { return getProgram().emitBuildInfo(writeFile, cancellationToken); },
89730             getAllDependencies: ts.notImplemented,
89731             getCurrentDirectory: function () { return getProgram().getCurrentDirectory(); },
89732             close: ts.noop,
89733         };
89734         function getProgram() {
89735             return ts.Debug.checkDefined(state.program);
89736         }
89737     }
89738     ts.createRedirectedBuilderProgram = createRedirectedBuilderProgram;
89739 })(ts || (ts = {}));
89740 var ts;
89741 (function (ts) {
89742     function createSemanticDiagnosticsBuilderProgram(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
89743         return ts.createBuilderProgram(ts.BuilderProgramKind.SemanticDiagnosticsBuilderProgram, ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences));
89744     }
89745     ts.createSemanticDiagnosticsBuilderProgram = createSemanticDiagnosticsBuilderProgram;
89746     function createEmitAndSemanticDiagnosticsBuilderProgram(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
89747         return ts.createBuilderProgram(ts.BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram, ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences));
89748     }
89749     ts.createEmitAndSemanticDiagnosticsBuilderProgram = createEmitAndSemanticDiagnosticsBuilderProgram;
89750     function createAbstractBuilder(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
89751         var _a = ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences), newProgram = _a.newProgram, newConfigFileParsingDiagnostics = _a.configFileParsingDiagnostics;
89752         return ts.createRedirectedBuilderProgram({ program: newProgram, compilerOptions: newProgram.getCompilerOptions() }, newConfigFileParsingDiagnostics);
89753     }
89754     ts.createAbstractBuilder = createAbstractBuilder;
89755 })(ts || (ts = {}));
89756 var ts;
89757 (function (ts) {
89758     function removeIgnoredPath(path) {
89759         if (ts.endsWith(path, "/node_modules/.staging")) {
89760             return ts.removeSuffix(path, "/.staging");
89761         }
89762         return ts.some(ts.ignoredPaths, function (searchPath) { return ts.stringContains(path, searchPath); }) ?
89763             undefined :
89764             path;
89765     }
89766     ts.removeIgnoredPath = removeIgnoredPath;
89767     function canWatchDirectory(dirPath) {
89768         var rootLength = ts.getRootLength(dirPath);
89769         if (dirPath.length === rootLength) {
89770             return false;
89771         }
89772         var nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, rootLength);
89773         if (nextDirectorySeparator === -1) {
89774             return false;
89775         }
89776         var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1);
89777         var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47;
89778         if (isNonDirectorySeparatorRoot &&
89779             dirPath.search(/[a-zA-Z]:/) !== 0 &&
89780             pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) {
89781             nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1);
89782             if (nextDirectorySeparator === -1) {
89783                 return false;
89784             }
89785             pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1);
89786         }
89787         if (isNonDirectorySeparatorRoot &&
89788             pathPartForUserCheck.search(/users\//i) !== 0) {
89789             return true;
89790         }
89791         for (var searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) {
89792             searchIndex = dirPath.indexOf(ts.directorySeparator, searchIndex) + 1;
89793             if (searchIndex === 0) {
89794                 return false;
89795             }
89796         }
89797         return true;
89798     }
89799     ts.canWatchDirectory = canWatchDirectory;
89800     function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
89801         var filesWithChangedSetOfUnresolvedImports;
89802         var filesWithInvalidatedResolutions;
89803         var filesWithInvalidatedNonRelativeUnresolvedImports;
89804         var nonRelativeExternalModuleResolutions = ts.createMultiMap();
89805         var resolutionsWithFailedLookups = [];
89806         var resolvedFileToResolution = ts.createMultiMap();
89807         var hasChangedAutomaticTypeDirectiveNames = false;
89808         var failedLookupChecks = [];
89809         var startsWithPathChecks = [];
89810         var isInDirectoryChecks = [];
89811         var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); });
89812         var cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost();
89813         var resolvedModuleNames = new ts.Map();
89814         var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects();
89815         var nonRelativeModuleNameCache = ts.createCacheWithRedirects();
89816         var moduleResolutionCache = ts.createModuleResolutionCacheWithMaps(perDirectoryResolvedModuleNames, nonRelativeModuleNameCache, getCurrentDirectory(), resolutionHost.getCanonicalFileName);
89817         var resolvedTypeReferenceDirectives = new ts.Map();
89818         var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects();
89819         var failedLookupDefaultExtensions = [".ts", ".tsx", ".js", ".jsx", ".json"];
89820         var customFailedLookupPaths = new ts.Map();
89821         var directoryWatchesOfFailedLookups = new ts.Map();
89822         var rootDir = rootDirForResolution && ts.removeTrailingDirectorySeparator(ts.getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
89823         var rootPath = (rootDir && resolutionHost.toPath(rootDir));
89824         var rootSplitLength = rootPath !== undefined ? rootPath.split(ts.directorySeparator).length : 0;
89825         var typeRootsWatches = new ts.Map();
89826         return {
89827             startRecordingFilesWithChangedResolutions: startRecordingFilesWithChangedResolutions,
89828             finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions,
89829             startCachingPerDirectoryResolution: clearPerDirectoryResolutions,
89830             finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution,
89831             resolveModuleNames: resolveModuleNames,
89832             getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
89833             resolveTypeReferenceDirectives: resolveTypeReferenceDirectives,
89834             removeResolutionsFromProjectReferenceRedirects: removeResolutionsFromProjectReferenceRedirects,
89835             removeResolutionsOfFile: removeResolutionsOfFile,
89836             hasChangedAutomaticTypeDirectiveNames: function () { return hasChangedAutomaticTypeDirectiveNames; },
89837             invalidateResolutionOfFile: invalidateResolutionOfFile,
89838             invalidateResolutionsOfFailedLookupLocations: invalidateResolutionsOfFailedLookupLocations,
89839             setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports,
89840             createHasInvalidatedResolution: createHasInvalidatedResolution,
89841             updateTypeRootsWatch: updateTypeRootsWatch,
89842             closeTypeRootsWatch: closeTypeRootsWatch,
89843             clear: clear
89844         };
89845         function getResolvedModule(resolution) {
89846             return resolution.resolvedModule;
89847         }
89848         function getResolvedTypeReferenceDirective(resolution) {
89849             return resolution.resolvedTypeReferenceDirective;
89850         }
89851         function isInDirectoryPath(dir, file) {
89852             if (dir === undefined || file.length <= dir.length) {
89853                 return false;
89854             }
89855             return ts.startsWith(file, dir) && file[dir.length] === ts.directorySeparator;
89856         }
89857         function clear() {
89858             ts.clearMap(directoryWatchesOfFailedLookups, ts.closeFileWatcherOf);
89859             customFailedLookupPaths.clear();
89860             nonRelativeExternalModuleResolutions.clear();
89861             closeTypeRootsWatch();
89862             resolvedModuleNames.clear();
89863             resolvedTypeReferenceDirectives.clear();
89864             resolvedFileToResolution.clear();
89865             resolutionsWithFailedLookups.length = 0;
89866             failedLookupChecks.length = 0;
89867             startsWithPathChecks.length = 0;
89868             isInDirectoryChecks.length = 0;
89869             clearPerDirectoryResolutions();
89870             hasChangedAutomaticTypeDirectiveNames = false;
89871         }
89872         function startRecordingFilesWithChangedResolutions() {
89873             filesWithChangedSetOfUnresolvedImports = [];
89874         }
89875         function finishRecordingFilesWithChangedResolutions() {
89876             var collected = filesWithChangedSetOfUnresolvedImports;
89877             filesWithChangedSetOfUnresolvedImports = undefined;
89878             return collected;
89879         }
89880         function isFileWithInvalidatedNonRelativeUnresolvedImports(path) {
89881             if (!filesWithInvalidatedNonRelativeUnresolvedImports) {
89882                 return false;
89883             }
89884             var value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path);
89885             return !!value && !!value.length;
89886         }
89887         function createHasInvalidatedResolution(forceAllFilesAsInvalidated) {
89888             invalidateResolutionsOfFailedLookupLocations();
89889             if (forceAllFilesAsInvalidated) {
89890                 filesWithInvalidatedResolutions = undefined;
89891                 return ts.returnTrue;
89892             }
89893             var collected = filesWithInvalidatedResolutions;
89894             filesWithInvalidatedResolutions = undefined;
89895             return function (path) { return (!!collected && collected.has(path)) ||
89896                 isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
89897         }
89898         function clearPerDirectoryResolutions() {
89899             perDirectoryResolvedModuleNames.clear();
89900             nonRelativeModuleNameCache.clear();
89901             perDirectoryResolvedTypeReferenceDirectives.clear();
89902             nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
89903             nonRelativeExternalModuleResolutions.clear();
89904         }
89905         function finishCachingPerDirectoryResolution() {
89906             filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
89907             clearPerDirectoryResolutions();
89908             directoryWatchesOfFailedLookups.forEach(function (watcher, path) {
89909                 if (watcher.refCount === 0) {
89910                     directoryWatchesOfFailedLookups.delete(path);
89911                     watcher.watcher.close();
89912                 }
89913             });
89914             hasChangedAutomaticTypeDirectiveNames = false;
89915         }
89916         function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference) {
89917             var _a;
89918             var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference);
89919             if (!resolutionHost.getGlobalCache) {
89920                 return primaryResult;
89921             }
89922             var globalCache = resolutionHost.getGlobalCache();
89923             if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) {
89924                 var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations;
89925                 if (resolvedModule) {
89926                     primaryResult.resolvedModule = resolvedModule;
89927                     (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
89928                     return primaryResult;
89929                 }
89930             }
89931             return primaryResult;
89932         }
89933         function resolveNamesWithLocalCache(_a) {
89934             var _b;
89935             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;
89936             var path = resolutionHost.toPath(containingFile);
89937             var resolutionsInFile = cache.get(path) || cache.set(path, new ts.Map()).get(path);
89938             var dirPath = ts.getDirectoryPath(path);
89939             var perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
89940             var perDirectoryResolution = perDirectoryCache.get(dirPath);
89941             if (!perDirectoryResolution) {
89942                 perDirectoryResolution = new ts.Map();
89943                 perDirectoryCache.set(dirPath, perDirectoryResolution);
89944             }
89945             var resolvedModules = [];
89946             var compilerOptions = resolutionHost.getCompilationSettings();
89947             var hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path);
89948             var program = resolutionHost.getCurrentProgram();
89949             var oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile);
89950             var unmatchedRedirects = oldRedirect ?
89951                 !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path :
89952                 !!redirectedReference;
89953             var seenNamesInFile = new ts.Map();
89954             for (var _i = 0, names_3 = names; _i < names_3.length; _i++) {
89955                 var name = names_3[_i];
89956                 var resolution = resolutionsInFile.get(name);
89957                 if (!seenNamesInFile.has(name) &&
89958                     unmatchedRedirects || !resolution || resolution.isInvalidated ||
89959                     (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) {
89960                     var existingResolution = resolution;
89961                     var resolutionInDirectory = perDirectoryResolution.get(name);
89962                     if (resolutionInDirectory) {
89963                         resolution = resolutionInDirectory;
89964                     }
89965                     else {
89966                         resolution = loader(name, containingFile, compilerOptions, ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost, redirectedReference);
89967                         perDirectoryResolution.set(name, resolution);
89968                     }
89969                     resolutionsInFile.set(name, resolution);
89970                     watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
89971                     if (existingResolution) {
89972                         stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolutionWithResolvedFileName);
89973                     }
89974                     if (logChanges && filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) {
89975                         filesWithChangedSetOfUnresolvedImports.push(path);
89976                         logChanges = false;
89977                     }
89978                 }
89979                 ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated);
89980                 seenNamesInFile.set(name, true);
89981                 resolvedModules.push(getResolutionWithResolvedFileName(resolution));
89982             }
89983             resolutionsInFile.forEach(function (resolution, name) {
89984                 if (!seenNamesInFile.has(name) && !ts.contains(reusedNames, name)) {
89985                     stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName);
89986                     resolutionsInFile.delete(name);
89987                 }
89988             });
89989             return resolvedModules;
89990             function resolutionIsEqualTo(oldResolution, newResolution) {
89991                 if (oldResolution === newResolution) {
89992                     return true;
89993                 }
89994                 if (!oldResolution || !newResolution) {
89995                     return false;
89996                 }
89997                 var oldResult = getResolutionWithResolvedFileName(oldResolution);
89998                 var newResult = getResolutionWithResolvedFileName(newResolution);
89999                 if (oldResult === newResult) {
90000                     return true;
90001                 }
90002                 if (!oldResult || !newResult) {
90003                     return false;
90004                 }
90005                 return oldResult.resolvedFileName === newResult.resolvedFileName;
90006             }
90007         }
90008         function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference) {
90009             return resolveNamesWithLocalCache({
90010                 names: typeDirectiveNames,
90011                 containingFile: containingFile,
90012                 redirectedReference: redirectedReference,
90013                 cache: resolvedTypeReferenceDirectives,
90014                 perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives,
90015                 loader: ts.resolveTypeReferenceDirective,
90016                 getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
90017                 shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
90018             });
90019         }
90020         function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference) {
90021             return resolveNamesWithLocalCache({
90022                 names: moduleNames,
90023                 containingFile: containingFile,
90024                 redirectedReference: redirectedReference,
90025                 cache: resolvedModuleNames,
90026                 perDirectoryCacheWithRedirects: perDirectoryResolvedModuleNames,
90027                 loader: resolveModuleName,
90028                 getResolutionWithResolvedFileName: getResolvedModule,
90029                 shouldRetryResolution: function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); },
90030                 reusedNames: reusedNames,
90031                 logChanges: logChangesWhenResolvingModule,
90032             });
90033         }
90034         function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) {
90035             var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile));
90036             return cache && cache.get(moduleName);
90037         }
90038         function isNodeModulesAtTypesDirectory(dirPath) {
90039             return ts.endsWith(dirPath, "/node_modules/@types");
90040         }
90041         function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath) {
90042             if (isInDirectoryPath(rootPath, failedLookupLocationPath)) {
90043                 failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
90044                 var failedLookupPathSplit = failedLookupLocationPath.split(ts.directorySeparator);
90045                 var failedLookupSplit = failedLookupLocation.split(ts.directorySeparator);
90046                 ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath);
90047                 if (failedLookupPathSplit.length > rootSplitLength + 1) {
90048                     return {
90049                         dir: failedLookupSplit.slice(0, rootSplitLength + 1).join(ts.directorySeparator),
90050                         dirPath: failedLookupPathSplit.slice(0, rootSplitLength + 1).join(ts.directorySeparator)
90051                     };
90052                 }
90053                 else {
90054                     return {
90055                         dir: rootDir,
90056                         dirPath: rootPath,
90057                         nonRecursive: false
90058                     };
90059                 }
90060             }
90061             return getDirectoryToWatchFromFailedLookupLocationDirectory(ts.getDirectoryPath(ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory())), ts.getDirectoryPath(failedLookupLocationPath));
90062         }
90063         function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath) {
90064             while (ts.pathContainsNodeModules(dirPath)) {
90065                 dir = ts.getDirectoryPath(dir);
90066                 dirPath = ts.getDirectoryPath(dirPath);
90067             }
90068             if (ts.isNodeModulesDirectory(dirPath)) {
90069                 return canWatchDirectory(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined;
90070             }
90071             var nonRecursive = true;
90072             var subDirectoryPath, subDirectory;
90073             if (rootPath !== undefined) {
90074                 while (!isInDirectoryPath(dirPath, rootPath)) {
90075                     var parentPath = ts.getDirectoryPath(dirPath);
90076                     if (parentPath === dirPath) {
90077                         break;
90078                     }
90079                     nonRecursive = false;
90080                     subDirectoryPath = dirPath;
90081                     subDirectory = dir;
90082                     dirPath = parentPath;
90083                     dir = ts.getDirectoryPath(dir);
90084                 }
90085             }
90086             return canWatchDirectory(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined;
90087         }
90088         function isPathWithDefaultFailedLookupExtension(path) {
90089             return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
90090         }
90091         function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
90092             if (resolution.refCount) {
90093                 resolution.refCount++;
90094                 ts.Debug.assertDefined(resolution.files);
90095             }
90096             else {
90097                 resolution.refCount = 1;
90098                 ts.Debug.assert(ts.length(resolution.files) === 0);
90099                 if (ts.isExternalModuleNameRelative(name)) {
90100                     watchFailedLookupLocationOfResolution(resolution);
90101                 }
90102                 else {
90103                     nonRelativeExternalModuleResolutions.add(name, resolution);
90104                 }
90105                 var resolved = getResolutionWithResolvedFileName(resolution);
90106                 if (resolved && resolved.resolvedFileName) {
90107                     resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution);
90108                 }
90109             }
90110             (resolution.files || (resolution.files = [])).push(filePath);
90111         }
90112         function watchFailedLookupLocationOfResolution(resolution) {
90113             ts.Debug.assert(!!resolution.refCount);
90114             var failedLookupLocations = resolution.failedLookupLocations;
90115             if (!failedLookupLocations.length)
90116                 return;
90117             resolutionsWithFailedLookups.push(resolution);
90118             var setAtRoot = false;
90119             for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) {
90120                 var failedLookupLocation = failedLookupLocations_1[_i];
90121                 var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
90122                 var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
90123                 if (toWatch) {
90124                     var dir = toWatch.dir, dirPath = toWatch.dirPath, nonRecursive = toWatch.nonRecursive;
90125                     if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) {
90126                         var refCount = customFailedLookupPaths.get(failedLookupLocationPath) || 0;
90127                         customFailedLookupPaths.set(failedLookupLocationPath, refCount + 1);
90128                     }
90129                     if (dirPath === rootPath) {
90130                         ts.Debug.assert(!nonRecursive);
90131                         setAtRoot = true;
90132                     }
90133                     else {
90134                         setDirectoryWatcher(dir, dirPath, nonRecursive);
90135                     }
90136                 }
90137             }
90138             if (setAtRoot) {
90139                 setDirectoryWatcher(rootDir, rootPath, true);
90140             }
90141         }
90142         function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
90143             var program = resolutionHost.getCurrentProgram();
90144             if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
90145                 resolutions.forEach(watchFailedLookupLocationOfResolution);
90146             }
90147         }
90148         function setDirectoryWatcher(dir, dirPath, nonRecursive) {
90149             var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
90150             if (dirWatcher) {
90151                 ts.Debug.assert(!!nonRecursive === !!dirWatcher.nonRecursive);
90152                 dirWatcher.refCount++;
90153             }
90154             else {
90155                 directoryWatchesOfFailedLookups.set(dirPath, { watcher: createDirectoryWatcher(dir, dirPath, nonRecursive), refCount: 1, nonRecursive: nonRecursive });
90156             }
90157         }
90158         function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
90159             ts.unorderedRemoveItem(ts.Debug.assertDefined(resolution.files), filePath);
90160             resolution.refCount--;
90161             if (resolution.refCount) {
90162                 return;
90163             }
90164             var resolved = getResolutionWithResolvedFileName(resolution);
90165             if (resolved && resolved.resolvedFileName) {
90166                 resolvedFileToResolution.remove(resolutionHost.toPath(resolved.resolvedFileName), resolution);
90167             }
90168             if (!ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
90169                 return;
90170             }
90171             var failedLookupLocations = resolution.failedLookupLocations;
90172             var removeAtRoot = false;
90173             for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) {
90174                 var failedLookupLocation = failedLookupLocations_2[_i];
90175                 var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
90176                 var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
90177                 if (toWatch) {
90178                     var dirPath = toWatch.dirPath;
90179                     var refCount = customFailedLookupPaths.get(failedLookupLocationPath);
90180                     if (refCount) {
90181                         if (refCount === 1) {
90182                             customFailedLookupPaths.delete(failedLookupLocationPath);
90183                         }
90184                         else {
90185                             ts.Debug.assert(refCount > 1);
90186                             customFailedLookupPaths.set(failedLookupLocationPath, refCount - 1);
90187                         }
90188                     }
90189                     if (dirPath === rootPath) {
90190                         removeAtRoot = true;
90191                     }
90192                     else {
90193                         removeDirectoryWatcher(dirPath);
90194                     }
90195                 }
90196             }
90197             if (removeAtRoot) {
90198                 removeDirectoryWatcher(rootPath);
90199             }
90200         }
90201         function removeDirectoryWatcher(dirPath) {
90202             var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
90203             dirWatcher.refCount--;
90204         }
90205         function createDirectoryWatcher(directory, dirPath, nonRecursive) {
90206             return resolutionHost.watchDirectoryOfFailedLookupLocation(directory, function (fileOrDirectory) {
90207                 var fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
90208                 if (cachedDirectoryStructureHost) {
90209                     cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
90210                 }
90211                 scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
90212             }, nonRecursive ? 0 : 1);
90213         }
90214         function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) {
90215             var resolutions = cache.get(filePath);
90216             if (resolutions) {
90217                 resolutions.forEach(function (resolution) { return stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName); });
90218                 cache.delete(filePath);
90219             }
90220         }
90221         function removeResolutionsFromProjectReferenceRedirects(filePath) {
90222             if (!ts.fileExtensionIs(filePath, ".json")) {
90223                 return;
90224             }
90225             var program = resolutionHost.getCurrentProgram();
90226             if (!program) {
90227                 return;
90228             }
90229             var resolvedProjectReference = program.getResolvedProjectReferenceByPath(filePath);
90230             if (!resolvedProjectReference) {
90231                 return;
90232             }
90233             resolvedProjectReference.commandLine.fileNames.forEach(function (f) { return removeResolutionsOfFile(resolutionHost.toPath(f)); });
90234         }
90235         function removeResolutionsOfFile(filePath) {
90236             removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModule);
90237             removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirective);
90238         }
90239         function invalidateResolutions(resolutions, canInvalidate) {
90240             if (!resolutions)
90241                 return false;
90242             var invalidated = false;
90243             for (var _i = 0, resolutions_1 = resolutions; _i < resolutions_1.length; _i++) {
90244                 var resolution = resolutions_1[_i];
90245                 if (resolution.isInvalidated || !canInvalidate(resolution))
90246                     continue;
90247                 resolution.isInvalidated = invalidated = true;
90248                 for (var _a = 0, _b = ts.Debug.assertDefined(resolution.files); _a < _b.length; _a++) {
90249                     var containingFilePath = _b[_a];
90250                     (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath);
90251                     hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || ts.endsWith(containingFilePath, ts.inferredTypesContainingFile);
90252                 }
90253             }
90254             return invalidated;
90255         }
90256         function invalidateResolutionOfFile(filePath) {
90257             removeResolutionsOfFile(filePath);
90258             var prevHasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
90259             if (invalidateResolutions(resolvedFileToResolution.get(filePath), ts.returnTrue) &&
90260                 hasChangedAutomaticTypeDirectiveNames &&
90261                 !prevHasChangedAutomaticTypeDirectiveNames) {
90262                 resolutionHost.onChangedAutomaticTypeDirectiveNames();
90263             }
90264         }
90265         function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap) {
90266             ts.Debug.assert(filesWithInvalidatedNonRelativeUnresolvedImports === filesMap || filesWithInvalidatedNonRelativeUnresolvedImports === undefined);
90267             filesWithInvalidatedNonRelativeUnresolvedImports = filesMap;
90268         }
90269         function scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, isCreatingWatchedDirectory) {
90270             if (isCreatingWatchedDirectory) {
90271                 isInDirectoryChecks.push(fileOrDirectoryPath);
90272             }
90273             else {
90274                 var updatedPath = removeIgnoredPath(fileOrDirectoryPath);
90275                 if (!updatedPath)
90276                     return false;
90277                 fileOrDirectoryPath = updatedPath;
90278                 if (resolutionHost.fileIsOpen(fileOrDirectoryPath)) {
90279                     return false;
90280                 }
90281                 var dirOfFileOrDirectory = ts.getDirectoryPath(fileOrDirectoryPath);
90282                 if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || ts.isNodeModulesDirectory(fileOrDirectoryPath) ||
90283                     isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || ts.isNodeModulesDirectory(dirOfFileOrDirectory)) {
90284                     failedLookupChecks.push(fileOrDirectoryPath);
90285                     startsWithPathChecks.push(fileOrDirectoryPath);
90286                 }
90287                 else {
90288                     if (!isPathWithDefaultFailedLookupExtension(fileOrDirectoryPath) && !customFailedLookupPaths.has(fileOrDirectoryPath)) {
90289                         return false;
90290                     }
90291                     if (ts.isEmittedFileOfProgram(resolutionHost.getCurrentProgram(), fileOrDirectoryPath)) {
90292                         return false;
90293                     }
90294                     failedLookupChecks.push(fileOrDirectoryPath);
90295                 }
90296             }
90297             resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
90298         }
90299         function invalidateResolutionsOfFailedLookupLocations() {
90300             if (!failedLookupChecks.length && !startsWithPathChecks.length && !isInDirectoryChecks.length) {
90301                 return false;
90302             }
90303             var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution);
90304             failedLookupChecks.length = 0;
90305             startsWithPathChecks.length = 0;
90306             isInDirectoryChecks.length = 0;
90307             return invalidated;
90308         }
90309         function canInvalidateFailedLookupResolution(resolution) {
90310             return resolution.failedLookupLocations.some(function (location) {
90311                 var locationPath = resolutionHost.toPath(location);
90312                 return ts.contains(failedLookupChecks, locationPath) ||
90313                     startsWithPathChecks.some(function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath); }) ||
90314                     isInDirectoryChecks.some(function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath); });
90315             });
90316         }
90317         function closeTypeRootsWatch() {
90318             ts.clearMap(typeRootsWatches, ts.closeFileWatcher);
90319         }
90320         function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath) {
90321             if (isInDirectoryPath(rootPath, typeRootPath)) {
90322                 return rootPath;
90323             }
90324             var toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath);
90325             return toWatch && directoryWatchesOfFailedLookups.has(toWatch.dirPath) ? toWatch.dirPath : undefined;
90326         }
90327         function createTypeRootsWatch(typeRootPath, typeRoot) {
90328             return resolutionHost.watchTypeRootsDirectory(typeRoot, function (fileOrDirectory) {
90329                 var fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
90330                 if (cachedDirectoryStructureHost) {
90331                     cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
90332                 }
90333                 hasChangedAutomaticTypeDirectiveNames = true;
90334                 resolutionHost.onChangedAutomaticTypeDirectiveNames();
90335                 var dirPath = getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath);
90336                 if (dirPath) {
90337                     scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
90338                 }
90339             }, 1);
90340         }
90341         function updateTypeRootsWatch() {
90342             var options = resolutionHost.getCompilationSettings();
90343             if (options.types) {
90344                 closeTypeRootsWatch();
90345                 return;
90346             }
90347             var typeRoots = ts.getEffectiveTypeRoots(options, { directoryExists: directoryExistsForTypeRootWatch, getCurrentDirectory: getCurrentDirectory });
90348             if (typeRoots) {
90349                 ts.mutateMap(typeRootsWatches, ts.arrayToMap(typeRoots, function (tr) { return resolutionHost.toPath(tr); }), {
90350                     createNewValue: createTypeRootsWatch,
90351                     onDeleteValue: ts.closeFileWatcher
90352                 });
90353             }
90354             else {
90355                 closeTypeRootsWatch();
90356             }
90357         }
90358         function directoryExistsForTypeRootWatch(nodeTypesDirectory) {
90359             var dir = ts.getDirectoryPath(ts.getDirectoryPath(nodeTypesDirectory));
90360             var dirPath = resolutionHost.toPath(dir);
90361             return dirPath === rootPath || canWatchDirectory(dirPath);
90362         }
90363     }
90364     ts.createResolutionCache = createResolutionCache;
90365 })(ts || (ts = {}));
90366 var ts;
90367 (function (ts) {
90368     var moduleSpecifiers;
90369     (function (moduleSpecifiers) {
90370         function getPreferences(_a, compilerOptions, importingSourceFile) {
90371             var importModuleSpecifierPreference = _a.importModuleSpecifierPreference, importModuleSpecifierEnding = _a.importModuleSpecifierEnding;
90372             return {
90373                 relativePreference: importModuleSpecifierPreference === "relative" ? 0 : importModuleSpecifierPreference === "non-relative" ? 1 : 2,
90374                 ending: getEnding(),
90375             };
90376             function getEnding() {
90377                 switch (importModuleSpecifierEnding) {
90378                     case "minimal": return 0;
90379                     case "index": return 1;
90380                     case "js": return 2;
90381                     default: return usesJsExtensionOnImports(importingSourceFile) ? 2
90382                         : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 : 0;
90383                 }
90384             }
90385         }
90386         function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) {
90387             return {
90388                 relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 : 1,
90389                 ending: ts.hasJSFileExtension(oldImportSpecifier) ?
90390                     2 :
90391                     ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 : 0,
90392             };
90393         }
90394         function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, oldImportSpecifier) {
90395             var res = getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier));
90396             if (res === oldImportSpecifier)
90397                 return undefined;
90398             return res;
90399         }
90400         moduleSpecifiers.updateModuleSpecifier = updateModuleSpecifier;
90401         function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences) {
90402             if (preferences === void 0) { preferences = {}; }
90403             return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences(preferences, compilerOptions, importingSourceFile));
90404         }
90405         moduleSpecifiers.getModuleSpecifier = getModuleSpecifier;
90406         function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host) {
90407             var info = getInfo(importingSourceFileName, host);
90408             var modulePaths = getAllModulePaths(importingSourceFileName, nodeModulesFileName, host);
90409             return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions, true); });
90410         }
90411         moduleSpecifiers.getNodeModulesPackageName = getNodeModulesPackageName;
90412         function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, preferences) {
90413             var info = getInfo(importingSourceFileName, host);
90414             var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host);
90415             return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions); }) ||
90416                 getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
90417         }
90418         function getModuleSpecifiers(moduleSymbol, compilerOptions, importingSourceFile, host, userPreferences) {
90419             var ambient = tryGetModuleNameFromAmbientModule(moduleSymbol);
90420             if (ambient)
90421                 return [ambient];
90422             var info = getInfo(importingSourceFile.path, host);
90423             var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol));
90424             var modulePaths = getAllModulePaths(importingSourceFile.path, moduleSourceFile.originalFileName, host);
90425             var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile);
90426             var importedFileIsInNodeModules = ts.some(modulePaths, function (p) { return p.isInNodeModules; });
90427             var nodeModulesSpecifiers;
90428             var pathsSpecifiers;
90429             var relativeSpecifiers;
90430             for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) {
90431                 var modulePath = modulePaths_1[_i];
90432                 var specifier = tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions);
90433                 nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier);
90434                 if (specifier && modulePath.isRedirect) {
90435                     return nodeModulesSpecifiers;
90436                 }
90437                 if (!specifier && !modulePath.isRedirect) {
90438                     var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, preferences);
90439                     if (ts.pathIsBareSpecifier(local)) {
90440                         pathsSpecifiers = ts.append(pathsSpecifiers, local);
90441                     }
90442                     else if (!importedFileIsInNodeModules || modulePath.isInNodeModules) {
90443                         relativeSpecifiers = ts.append(relativeSpecifiers, local);
90444                     }
90445                 }
90446             }
90447             return (pathsSpecifiers === null || pathsSpecifiers === void 0 ? void 0 : pathsSpecifiers.length) ? pathsSpecifiers :
90448                 (nodeModulesSpecifiers === null || nodeModulesSpecifiers === void 0 ? void 0 : nodeModulesSpecifiers.length) ? nodeModulesSpecifiers :
90449                     ts.Debug.checkDefined(relativeSpecifiers);
90450         }
90451         moduleSpecifiers.getModuleSpecifiers = getModuleSpecifiers;
90452         function getInfo(importingSourceFileName, host) {
90453             var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : true);
90454             var sourceDirectory = ts.getDirectoryPath(importingSourceFileName);
90455             return { getCanonicalFileName: getCanonicalFileName, sourceDirectory: sourceDirectory };
90456         }
90457         function getLocalModuleSpecifier(moduleFileName, _a, compilerOptions, host, _b) {
90458             var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory;
90459             var ending = _b.ending, relativePreference = _b.relativePreference;
90460             var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs;
90461             var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) ||
90462                 removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions);
90463             if (!baseUrl && !paths || relativePreference === 0) {
90464                 return relativePath;
90465             }
90466             var baseDirectory = ts.getPathsBasePath(compilerOptions, host) || baseUrl;
90467             var relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseDirectory, getCanonicalFileName);
90468             if (!relativeToBaseUrl) {
90469                 return relativePath;
90470             }
90471             var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions);
90472             var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths);
90473             var nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths;
90474             if (!nonRelative) {
90475                 return relativePath;
90476             }
90477             if (relativePreference === 1) {
90478                 return nonRelative;
90479             }
90480             if (relativePreference !== 2)
90481                 ts.Debug.assertNever(relativePreference);
90482             return isPathRelativeToParent(nonRelative) || countPathComponents(relativePath) < countPathComponents(nonRelative) ? relativePath : nonRelative;
90483         }
90484         function countPathComponents(path) {
90485             var count = 0;
90486             for (var i = ts.startsWith(path, "./") ? 2 : 0; i < path.length; i++) {
90487                 if (path.charCodeAt(i) === 47)
90488                     count++;
90489             }
90490             return count;
90491         }
90492         moduleSpecifiers.countPathComponents = countPathComponents;
90493         function usesJsExtensionOnImports(_a) {
90494             var imports = _a.imports;
90495             return ts.firstDefined(imports, function (_a) {
90496                 var text = _a.text;
90497                 return ts.pathIsRelative(text) ? ts.hasJSFileExtension(text) : undefined;
90498             }) || false;
90499         }
90500         function numberOfDirectorySeparators(str) {
90501             var match = str.match(/\//g);
90502             return match ? match.length : 0;
90503         }
90504         function comparePathsByRedirectAndNumberOfDirectorySeparators(a, b) {
90505             return ts.compareBooleans(b.isRedirect, a.isRedirect) || ts.compareValues(numberOfDirectorySeparators(a.path), numberOfDirectorySeparators(b.path));
90506         }
90507         function forEachFileNameOfModule(importingFileName, importedFileName, host, preferSymlinks, cb) {
90508             var getCanonicalFileName = ts.hostGetCanonicalFileName(host);
90509             var cwd = host.getCurrentDirectory();
90510             var referenceRedirect = host.isSourceOfProjectReferenceRedirect(importedFileName) ? host.getProjectReferenceRedirect(importedFileName) : undefined;
90511             var redirects = host.redirectTargetsMap.get(ts.toPath(importedFileName, cwd, getCanonicalFileName)) || ts.emptyArray;
90512             var importedFileNames = __spreadArrays((referenceRedirect ? [referenceRedirect] : ts.emptyArray), [importedFileName], redirects);
90513             var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); });
90514             if (!preferSymlinks) {
90515                 var result_15 = ts.forEach(targets, function (p) { return cb(p, referenceRedirect === p); });
90516                 if (result_15)
90517                     return result_15;
90518             }
90519             var links = host.getSymlinkCache
90520                 ? host.getSymlinkCache()
90521                 : ts.discoverProbableSymlinks(host.getSourceFiles(), getCanonicalFileName, cwd);
90522             var symlinkedDirectories = links.getSymlinkedDirectories();
90523             var useCaseSensitiveFileNames = !host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames();
90524             var result = symlinkedDirectories && ts.forEachEntry(symlinkedDirectories, function (resolved, path) {
90525                 if (resolved === false)
90526                     return undefined;
90527                 if (ts.startsWithDirectory(importingFileName, resolved.realPath, getCanonicalFileName)) {
90528                     return undefined;
90529                 }
90530                 return ts.forEach(targets, function (target) {
90531                     if (!ts.containsPath(resolved.real, target, !useCaseSensitiveFileNames)) {
90532                         return;
90533                     }
90534                     var relative = ts.getRelativePathFromDirectory(resolved.real, target, getCanonicalFileName);
90535                     var option = ts.resolvePath(path, relative);
90536                     if (!host.fileExists || host.fileExists(option)) {
90537                         var result_16 = cb(option, target === referenceRedirect);
90538                         if (result_16)
90539                             return result_16;
90540                     }
90541                 });
90542             });
90543             return result ||
90544                 (preferSymlinks ? ts.forEach(targets, function (p) { return cb(p, p === referenceRedirect); }) : undefined);
90545         }
90546         moduleSpecifiers.forEachFileNameOfModule = forEachFileNameOfModule;
90547         function getAllModulePaths(importingFileName, importedFileName, host) {
90548             var cwd = host.getCurrentDirectory();
90549             var getCanonicalFileName = ts.hostGetCanonicalFileName(host);
90550             var allFileNames = new ts.Map();
90551             var importedFileFromNodeModules = false;
90552             forEachFileNameOfModule(importingFileName, importedFileName, host, true, function (path, isRedirect) {
90553                 var isInNodeModules = ts.pathContainsNodeModules(path);
90554                 allFileNames.set(path, { path: getCanonicalFileName(path), isRedirect: isRedirect, isInNodeModules: isInNodeModules });
90555                 importedFileFromNodeModules = importedFileFromNodeModules || isInNodeModules;
90556             });
90557             var sortedPaths = [];
90558             var _loop_24 = function (directory) {
90559                 var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
90560                 var pathsInDirectory;
90561                 allFileNames.forEach(function (_a, fileName) {
90562                     var path = _a.path, isRedirect = _a.isRedirect, isInNodeModules = _a.isInNodeModules;
90563                     if (ts.startsWith(path, directoryStart)) {
90564                         (pathsInDirectory || (pathsInDirectory = [])).push({ path: fileName, isRedirect: isRedirect, isInNodeModules: isInNodeModules });
90565                         allFileNames.delete(fileName);
90566                     }
90567                 });
90568                 if (pathsInDirectory) {
90569                     if (pathsInDirectory.length > 1) {
90570                         pathsInDirectory.sort(comparePathsByRedirectAndNumberOfDirectorySeparators);
90571                     }
90572                     sortedPaths.push.apply(sortedPaths, pathsInDirectory);
90573                 }
90574                 var newDirectory = ts.getDirectoryPath(directory);
90575                 if (newDirectory === directory)
90576                     return out_directory_1 = directory, "break";
90577                 directory = newDirectory;
90578                 out_directory_1 = directory;
90579             };
90580             var out_directory_1;
90581             for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) {
90582                 var state_8 = _loop_24(directory);
90583                 directory = out_directory_1;
90584                 if (state_8 === "break")
90585                     break;
90586             }
90587             if (allFileNames.size) {
90588                 var remainingPaths = ts.arrayFrom(allFileNames.values());
90589                 if (remainingPaths.length > 1)
90590                     remainingPaths.sort(comparePathsByRedirectAndNumberOfDirectorySeparators);
90591                 sortedPaths.push.apply(sortedPaths, remainingPaths);
90592             }
90593             return sortedPaths;
90594         }
90595         function tryGetModuleNameFromAmbientModule(moduleSymbol) {
90596             var decl = ts.find(moduleSymbol.declarations, function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); });
90597             if (decl) {
90598                 return decl.name.text;
90599             }
90600         }
90601         function tryGetModuleNameFromPaths(relativeToBaseUrlWithIndex, relativeToBaseUrl, paths) {
90602             for (var key in paths) {
90603                 for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
90604                     var patternText_1 = _a[_i];
90605                     var pattern = ts.removeFileExtension(ts.normalizePath(patternText_1));
90606                     var indexOfStar = pattern.indexOf("*");
90607                     if (indexOfStar !== -1) {
90608                         var prefix = pattern.substr(0, indexOfStar);
90609                         var suffix = pattern.substr(indexOfStar + 1);
90610                         if (relativeToBaseUrl.length >= prefix.length + suffix.length &&
90611                             ts.startsWith(relativeToBaseUrl, prefix) &&
90612                             ts.endsWith(relativeToBaseUrl, suffix) ||
90613                             !suffix && relativeToBaseUrl === ts.removeTrailingDirectorySeparator(prefix)) {
90614                             var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length);
90615                             return key.replace("*", matchedStar);
90616                         }
90617                     }
90618                     else if (pattern === relativeToBaseUrl || pattern === relativeToBaseUrlWithIndex) {
90619                         return key;
90620                     }
90621                 }
90622             }
90623         }
90624         function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) {
90625             var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
90626             if (normalizedTargetPath === undefined) {
90627                 return undefined;
90628             }
90629             var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName);
90630             var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath;
90631             return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs
90632                 ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
90633                 : ts.removeFileExtension(relativePath);
90634         }
90635         function tryGetModuleNameAsNodeModule(_a, _b, host, options, packageNameOnly) {
90636             var path = _a.path, isRedirect = _a.isRedirect;
90637             var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory;
90638             if (!host.fileExists || !host.readFile) {
90639                 return undefined;
90640             }
90641             var parts = getNodeModulePathParts(path);
90642             if (!parts) {
90643                 return undefined;
90644             }
90645             var moduleSpecifier = path;
90646             var isPackageRootPath = false;
90647             if (!packageNameOnly) {
90648                 var packageRootIndex = parts.packageRootIndex;
90649                 var moduleFileNameForExtensionless = void 0;
90650                 while (true) {
90651                     var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath;
90652                     if (packageRootPath) {
90653                         moduleSpecifier = packageRootPath;
90654                         isPackageRootPath = true;
90655                         break;
90656                     }
90657                     if (!moduleFileNameForExtensionless)
90658                         moduleFileNameForExtensionless = moduleFileToTry;
90659                     packageRootIndex = path.indexOf(ts.directorySeparator, packageRootIndex + 1);
90660                     if (packageRootIndex === -1) {
90661                         moduleSpecifier = getExtensionlessFileName(moduleFileNameForExtensionless);
90662                         break;
90663                     }
90664                 }
90665             }
90666             if (isRedirect && !isPackageRootPath) {
90667                 return undefined;
90668             }
90669             var globalTypingsCacheLocation = host.getGlobalTypingsCacheLocation && host.getGlobalTypingsCacheLocation();
90670             var pathToTopLevelNodeModules = getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex));
90671             if (!(ts.startsWith(sourceDirectory, pathToTopLevelNodeModules) || globalTypingsCacheLocation && ts.startsWith(getCanonicalFileName(globalTypingsCacheLocation), pathToTopLevelNodeModules))) {
90672                 return undefined;
90673             }
90674             var nodeModulesDirectoryName = moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1);
90675             var packageName = ts.getPackageNameFromTypesPackageName(nodeModulesDirectoryName);
90676             return ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs && packageName === nodeModulesDirectoryName ? undefined : packageName;
90677             function tryDirectoryWithPackageJson(packageRootIndex) {
90678                 var packageRootPath = path.substring(0, packageRootIndex);
90679                 var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
90680                 var moduleFileToTry = path;
90681                 if (host.fileExists(packageJsonPath)) {
90682                     var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
90683                     var versionPaths = packageJsonContent.typesVersions
90684                         ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions)
90685                         : undefined;
90686                     if (versionPaths) {
90687                         var subModuleName = path.slice(packageRootPath.length + 1);
90688                         var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0, options), versionPaths.paths);
90689                         if (fromPaths !== undefined) {
90690                             moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths);
90691                         }
90692                     }
90693                     var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main;
90694                     if (ts.isString(mainFileRelative)) {
90695                         var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
90696                         if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
90697                             return { packageRootPath: packageRootPath, moduleFileToTry: moduleFileToTry };
90698                         }
90699                     }
90700                 }
90701                 return { moduleFileToTry: moduleFileToTry };
90702             }
90703             function getExtensionlessFileName(path) {
90704                 var fullModulePathWithoutExtension = ts.removeFileExtension(path);
90705                 if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index" && !tryGetAnyFileFromPath(host, fullModulePathWithoutExtension.substring(0, parts.fileNameIndex))) {
90706                     return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex);
90707                 }
90708                 return fullModulePathWithoutExtension;
90709             }
90710         }
90711         function tryGetAnyFileFromPath(host, path) {
90712             if (!host.fileExists)
90713                 return;
90714             var extensions = ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 }]);
90715             for (var _i = 0, extensions_3 = extensions; _i < extensions_3.length; _i++) {
90716                 var e = extensions_3[_i];
90717                 var fullPath = path + e;
90718                 if (host.fileExists(fullPath)) {
90719                     return fullPath;
90720                 }
90721             }
90722         }
90723         function getNodeModulePathParts(fullPath) {
90724             var topLevelNodeModulesIndex = 0;
90725             var topLevelPackageNameIndex = 0;
90726             var packageRootIndex = 0;
90727             var fileNameIndex = 0;
90728             var partStart = 0;
90729             var partEnd = 0;
90730             var state = 0;
90731             while (partEnd >= 0) {
90732                 partStart = partEnd;
90733                 partEnd = fullPath.indexOf("/", partStart + 1);
90734                 switch (state) {
90735                     case 0:
90736                         if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
90737                             topLevelNodeModulesIndex = partStart;
90738                             topLevelPackageNameIndex = partEnd;
90739                             state = 1;
90740                         }
90741                         break;
90742                     case 1:
90743                     case 2:
90744                         if (state === 1 && fullPath.charAt(partStart + 1) === "@") {
90745                             state = 2;
90746                         }
90747                         else {
90748                             packageRootIndex = partEnd;
90749                             state = 3;
90750                         }
90751                         break;
90752                     case 3:
90753                         if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
90754                             state = 1;
90755                         }
90756                         else {
90757                             state = 3;
90758                         }
90759                         break;
90760                 }
90761             }
90762             fileNameIndex = partStart;
90763             return state > 1 ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
90764         }
90765         function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
90766             return ts.firstDefined(rootDirs, function (rootDir) {
90767                 var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
90768                 return isPathRelativeToParent(relativePath) ? undefined : relativePath;
90769             });
90770         }
90771         function removeExtensionAndIndexPostFix(fileName, ending, options) {
90772             if (ts.fileExtensionIs(fileName, ".json"))
90773                 return fileName;
90774             var noExtension = ts.removeFileExtension(fileName);
90775             switch (ending) {
90776                 case 0:
90777                     return ts.removeSuffix(noExtension, "/index");
90778                 case 1:
90779                     return noExtension;
90780                 case 2:
90781                     return noExtension + getJSExtensionForFile(fileName, options);
90782                 default:
90783                     return ts.Debug.assertNever(ending);
90784             }
90785         }
90786         function getJSExtensionForFile(fileName, options) {
90787             var ext = ts.extensionFromPath(fileName);
90788             switch (ext) {
90789                 case ".ts":
90790                 case ".d.ts":
90791                     return ".js";
90792                 case ".tsx":
90793                     return options.jsx === 1 ? ".jsx" : ".js";
90794                 case ".js":
90795                 case ".jsx":
90796                 case ".json":
90797                     return ext;
90798                 case ".tsbuildinfo":
90799                     return ts.Debug.fail("Extension " + ".tsbuildinfo" + " is unsupported:: FileName:: " + fileName);
90800                 default:
90801                     return ts.Debug.assertNever(ext);
90802             }
90803         }
90804         function getRelativePathIfInDirectory(path, directoryPath, getCanonicalFileName) {
90805             var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false);
90806             return ts.isRootedDiskPath(relativePath) ? undefined : relativePath;
90807         }
90808         function isPathRelativeToParent(path) {
90809             return ts.startsWith(path, "..");
90810         }
90811     })(moduleSpecifiers = ts.moduleSpecifiers || (ts.moduleSpecifiers = {}));
90812 })(ts || (ts = {}));
90813 var ts;
90814 (function (ts) {
90815     var sysFormatDiagnosticsHost = ts.sys ? {
90816         getCurrentDirectory: function () { return ts.sys.getCurrentDirectory(); },
90817         getNewLine: function () { return ts.sys.newLine; },
90818         getCanonicalFileName: ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)
90819     } : undefined;
90820     function createDiagnosticReporter(system, pretty) {
90821         var host = system === ts.sys ? sysFormatDiagnosticsHost : {
90822             getCurrentDirectory: function () { return system.getCurrentDirectory(); },
90823             getNewLine: function () { return system.newLine; },
90824             getCanonicalFileName: ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames),
90825         };
90826         if (!pretty) {
90827             return function (diagnostic) { return system.write(ts.formatDiagnostic(diagnostic, host)); };
90828         }
90829         var diagnostics = new Array(1);
90830         return function (diagnostic) {
90831             diagnostics[0] = diagnostic;
90832             system.write(ts.formatDiagnosticsWithColorAndContext(diagnostics, host) + host.getNewLine());
90833             diagnostics[0] = undefined;
90834         };
90835     }
90836     ts.createDiagnosticReporter = createDiagnosticReporter;
90837     function clearScreenIfNotWatchingForFileChanges(system, diagnostic, options) {
90838         if (system.clearScreen &&
90839             !options.preserveWatchOutput &&
90840             !options.extendedDiagnostics &&
90841             !options.diagnostics &&
90842             ts.contains(ts.screenStartingMessageCodes, diagnostic.code)) {
90843             system.clearScreen();
90844             return true;
90845         }
90846         return false;
90847     }
90848     ts.screenStartingMessageCodes = [
90849         ts.Diagnostics.Starting_compilation_in_watch_mode.code,
90850         ts.Diagnostics.File_change_detected_Starting_incremental_compilation.code,
90851     ];
90852     function getPlainDiagnosticFollowingNewLines(diagnostic, newLine) {
90853         return ts.contains(ts.screenStartingMessageCodes, diagnostic.code)
90854             ? newLine + newLine
90855             : newLine;
90856     }
90857     function getLocaleTimeString(system) {
90858         return !system.now ?
90859             new Date().toLocaleTimeString() :
90860             system.now().toLocaleTimeString("en-US", { timeZone: "UTC" });
90861     }
90862     ts.getLocaleTimeString = getLocaleTimeString;
90863     function createWatchStatusReporter(system, pretty) {
90864         return pretty ?
90865             function (diagnostic, newLine, options) {
90866                 clearScreenIfNotWatchingForFileChanges(system, diagnostic, options);
90867                 var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] ";
90868                 output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine);
90869                 system.write(output);
90870             } :
90871             function (diagnostic, newLine, options) {
90872                 var output = "";
90873                 if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) {
90874                     output += newLine;
90875                 }
90876                 output += getLocaleTimeString(system) + " - ";
90877                 output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine);
90878                 system.write(output);
90879             };
90880     }
90881     ts.createWatchStatusReporter = createWatchStatusReporter;
90882     function parseConfigFileWithSystem(configFileName, optionsToExtend, watchOptionsToExtend, system, reportDiagnostic) {
90883         var host = system;
90884         host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic); };
90885         var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, undefined, watchOptionsToExtend);
90886         host.onUnRecoverableConfigFileDiagnostic = undefined;
90887         return result;
90888     }
90889     ts.parseConfigFileWithSystem = parseConfigFileWithSystem;
90890     function getErrorCountForSummary(diagnostics) {
90891         return ts.countWhere(diagnostics, function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; });
90892     }
90893     ts.getErrorCountForSummary = getErrorCountForSummary;
90894     function getWatchErrorSummaryDiagnosticMessage(errorCount) {
90895         return errorCount === 1 ?
90896             ts.Diagnostics.Found_1_error_Watching_for_file_changes :
90897             ts.Diagnostics.Found_0_errors_Watching_for_file_changes;
90898     }
90899     ts.getWatchErrorSummaryDiagnosticMessage = getWatchErrorSummaryDiagnosticMessage;
90900     function getErrorSummaryText(errorCount, newLine) {
90901         if (errorCount === 0)
90902             return "";
90903         var d = ts.createCompilerDiagnostic(errorCount === 1 ? ts.Diagnostics.Found_1_error : ts.Diagnostics.Found_0_errors, errorCount);
90904         return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine;
90905     }
90906     ts.getErrorSummaryText = getErrorSummaryText;
90907     function listFiles(program, writeFileName) {
90908         if (program.getCompilerOptions().listFiles || program.getCompilerOptions().listFilesOnly) {
90909             ts.forEach(program.getSourceFiles(), function (file) {
90910                 writeFileName(file.fileName);
90911             });
90912         }
90913     }
90914     ts.listFiles = listFiles;
90915     function emitFilesAndReportErrors(program, reportDiagnostic, writeFileName, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
90916         var isListFilesOnly = !!program.getCompilerOptions().listFilesOnly;
90917         var allDiagnostics = program.getConfigFileParsingDiagnostics().slice();
90918         var configFileParsingDiagnosticsLength = allDiagnostics.length;
90919         ts.addRange(allDiagnostics, program.getSyntacticDiagnostics(undefined, cancellationToken));
90920         if (allDiagnostics.length === configFileParsingDiagnosticsLength) {
90921             ts.addRange(allDiagnostics, program.getOptionsDiagnostics(cancellationToken));
90922             if (!isListFilesOnly) {
90923                 ts.addRange(allDiagnostics, program.getGlobalDiagnostics(cancellationToken));
90924                 if (allDiagnostics.length === configFileParsingDiagnosticsLength) {
90925                     ts.addRange(allDiagnostics, program.getSemanticDiagnostics(undefined, cancellationToken));
90926                 }
90927             }
90928         }
90929         var emitResult = isListFilesOnly
90930             ? { emitSkipped: true, diagnostics: ts.emptyArray }
90931             : program.emit(undefined, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers);
90932         var emittedFiles = emitResult.emittedFiles, emitDiagnostics = emitResult.diagnostics;
90933         ts.addRange(allDiagnostics, emitDiagnostics);
90934         var diagnostics = ts.sortAndDeduplicateDiagnostics(allDiagnostics);
90935         diagnostics.forEach(reportDiagnostic);
90936         if (writeFileName) {
90937             var currentDir_1 = program.getCurrentDirectory();
90938             ts.forEach(emittedFiles, function (file) {
90939                 var filepath = ts.getNormalizedAbsolutePath(file, currentDir_1);
90940                 writeFileName("TSFILE: " + filepath);
90941             });
90942             listFiles(program, writeFileName);
90943         }
90944         if (reportSummary) {
90945             reportSummary(getErrorCountForSummary(diagnostics));
90946         }
90947         return {
90948             emitResult: emitResult,
90949             diagnostics: diagnostics,
90950         };
90951     }
90952     ts.emitFilesAndReportErrors = emitFilesAndReportErrors;
90953     function emitFilesAndReportErrorsAndGetExitStatus(program, reportDiagnostic, writeFileName, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
90954         var _a = emitFilesAndReportErrors(program, reportDiagnostic, writeFileName, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers), emitResult = _a.emitResult, diagnostics = _a.diagnostics;
90955         if (emitResult.emitSkipped && diagnostics.length > 0) {
90956             return ts.ExitStatus.DiagnosticsPresent_OutputsSkipped;
90957         }
90958         else if (diagnostics.length > 0) {
90959             return ts.ExitStatus.DiagnosticsPresent_OutputsGenerated;
90960         }
90961         return ts.ExitStatus.Success;
90962     }
90963     ts.emitFilesAndReportErrorsAndGetExitStatus = emitFilesAndReportErrorsAndGetExitStatus;
90964     ts.noopFileWatcher = { close: ts.noop };
90965     ts.returnNoopFileWatcher = function () { return ts.noopFileWatcher; };
90966     function createWatchHost(system, reportWatchStatus) {
90967         if (system === void 0) { system = ts.sys; }
90968         var onWatchStatusChange = reportWatchStatus || createWatchStatusReporter(system);
90969         return {
90970             onWatchStatusChange: onWatchStatusChange,
90971             watchFile: ts.maybeBind(system, system.watchFile) || ts.returnNoopFileWatcher,
90972             watchDirectory: ts.maybeBind(system, system.watchDirectory) || ts.returnNoopFileWatcher,
90973             setTimeout: ts.maybeBind(system, system.setTimeout) || ts.noop,
90974             clearTimeout: ts.maybeBind(system, system.clearTimeout) || ts.noop
90975         };
90976     }
90977     ts.createWatchHost = createWatchHost;
90978     ts.WatchType = {
90979         ConfigFile: "Config file",
90980         SourceFile: "Source file",
90981         MissingFile: "Missing file",
90982         WildcardDirectory: "Wild card directory",
90983         FailedLookupLocations: "Failed Lookup Locations",
90984         TypeRoots: "Type roots"
90985     };
90986     function createWatchFactory(host, options) {
90987         var watchLogLevel = host.trace ? options.extendedDiagnostics ? ts.WatchLogLevel.Verbose : options.diagnostics ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None;
90988         var writeLog = watchLogLevel !== ts.WatchLogLevel.None ? (function (s) { return host.trace(s); }) : ts.noop;
90989         var result = ts.getWatchFactory(watchLogLevel, writeLog);
90990         result.writeLog = writeLog;
90991         return result;
90992     }
90993     ts.createWatchFactory = createWatchFactory;
90994     function createCompilerHostFromProgramHost(host, getCompilerOptions, directoryStructureHost) {
90995         if (directoryStructureHost === void 0) { directoryStructureHost = host; }
90996         var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames();
90997         var hostGetNewLine = ts.memoize(function () { return host.getNewLine(); });
90998         return {
90999             getSourceFile: function (fileName, languageVersion, onError) {
91000                 var text;
91001                 try {
91002                     ts.performance.mark("beforeIORead");
91003                     text = host.readFile(fileName, getCompilerOptions().charset);
91004                     ts.performance.mark("afterIORead");
91005                     ts.performance.measure("I/O Read", "beforeIORead", "afterIORead");
91006                 }
91007                 catch (e) {
91008                     if (onError) {
91009                         onError(e.message);
91010                     }
91011                     text = "";
91012                 }
91013                 return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion) : undefined;
91014             },
91015             getDefaultLibLocation: ts.maybeBind(host, host.getDefaultLibLocation),
91016             getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); },
91017             writeFile: writeFile,
91018             getCurrentDirectory: ts.memoize(function () { return host.getCurrentDirectory(); }),
91019             useCaseSensitiveFileNames: function () { return useCaseSensitiveFileNames; },
91020             getCanonicalFileName: ts.createGetCanonicalFileName(useCaseSensitiveFileNames),
91021             getNewLine: function () { return ts.getNewLineCharacter(getCompilerOptions(), hostGetNewLine); },
91022             fileExists: function (f) { return host.fileExists(f); },
91023             readFile: function (f) { return host.readFile(f); },
91024             trace: ts.maybeBind(host, host.trace),
91025             directoryExists: ts.maybeBind(directoryStructureHost, directoryStructureHost.directoryExists),
91026             getDirectories: ts.maybeBind(directoryStructureHost, directoryStructureHost.getDirectories),
91027             realpath: ts.maybeBind(host, host.realpath),
91028             getEnvironmentVariable: ts.maybeBind(host, host.getEnvironmentVariable) || (function () { return ""; }),
91029             createHash: ts.maybeBind(host, host.createHash),
91030             readDirectory: ts.maybeBind(host, host.readDirectory),
91031         };
91032         function writeFile(fileName, text, writeByteOrderMark, onError) {
91033             try {
91034                 ts.performance.mark("beforeIOWrite");
91035                 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); });
91036                 ts.performance.mark("afterIOWrite");
91037                 ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
91038             }
91039             catch (e) {
91040                 if (onError) {
91041                     onError(e.message);
91042                 }
91043             }
91044         }
91045     }
91046     ts.createCompilerHostFromProgramHost = createCompilerHostFromProgramHost;
91047     function setGetSourceFileAsHashVersioned(compilerHost, host) {
91048         var originalGetSourceFile = compilerHost.getSourceFile;
91049         var computeHash = ts.maybeBind(host, host.createHash) || ts.generateDjb2Hash;
91050         compilerHost.getSourceFile = function () {
91051             var args = [];
91052             for (var _i = 0; _i < arguments.length; _i++) {
91053                 args[_i] = arguments[_i];
91054             }
91055             var result = originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args));
91056             if (result) {
91057                 result.version = computeHash(result.text);
91058             }
91059             return result;
91060         };
91061     }
91062     ts.setGetSourceFileAsHashVersioned = setGetSourceFileAsHashVersioned;
91063     function createProgramHost(system, createProgram) {
91064         var getDefaultLibLocation = ts.memoize(function () { return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath())); });
91065         return {
91066             useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; },
91067             getNewLine: function () { return system.newLine; },
91068             getCurrentDirectory: ts.memoize(function () { return system.getCurrentDirectory(); }),
91069             getDefaultLibLocation: getDefaultLibLocation,
91070             getDefaultLibFileName: function (options) { return ts.combinePaths(getDefaultLibLocation(), ts.getDefaultLibFileName(options)); },
91071             fileExists: function (path) { return system.fileExists(path); },
91072             readFile: function (path, encoding) { return system.readFile(path, encoding); },
91073             directoryExists: function (path) { return system.directoryExists(path); },
91074             getDirectories: function (path) { return system.getDirectories(path); },
91075             readDirectory: function (path, extensions, exclude, include, depth) { return system.readDirectory(path, extensions, exclude, include, depth); },
91076             realpath: ts.maybeBind(system, system.realpath),
91077             getEnvironmentVariable: ts.maybeBind(system, system.getEnvironmentVariable),
91078             trace: function (s) { return system.write(s + system.newLine); },
91079             createDirectory: function (path) { return system.createDirectory(path); },
91080             writeFile: function (path, data, writeByteOrderMark) { return system.writeFile(path, data, writeByteOrderMark); },
91081             createHash: ts.maybeBind(system, system.createHash),
91082             createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram
91083         };
91084     }
91085     ts.createProgramHost = createProgramHost;
91086     function createWatchCompilerHost(system, createProgram, reportDiagnostic, reportWatchStatus) {
91087         if (system === void 0) { system = ts.sys; }
91088         var writeFileName = function (s) { return system.write(s + system.newLine); };
91089         var result = createProgramHost(system, createProgram);
91090         ts.copyProperties(result, createWatchHost(system, reportWatchStatus));
91091         result.afterProgramCreate = function (builderProgram) {
91092             var compilerOptions = builderProgram.getCompilerOptions();
91093             var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; });
91094             emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions, errorCount); });
91095         };
91096         return result;
91097     }
91098     function reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic) {
91099         reportDiagnostic(diagnostic);
91100         system.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
91101     }
91102     function createWatchCompilerHostOfConfigFile(_a) {
91103         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;
91104         var diagnosticReporter = reportDiagnostic || createDiagnosticReporter(system);
91105         var host = createWatchCompilerHost(system, createProgram, diagnosticReporter, reportWatchStatus);
91106         host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, diagnosticReporter, diagnostic); };
91107         host.configFileName = configFileName;
91108         host.optionsToExtend = optionsToExtend;
91109         host.watchOptionsToExtend = watchOptionsToExtend;
91110         host.extraFileExtensions = extraFileExtensions;
91111         return host;
91112     }
91113     ts.createWatchCompilerHostOfConfigFile = createWatchCompilerHostOfConfigFile;
91114     function createWatchCompilerHostOfFilesAndCompilerOptions(_a) {
91115         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;
91116         var host = createWatchCompilerHost(system, createProgram, reportDiagnostic || createDiagnosticReporter(system), reportWatchStatus);
91117         host.rootFiles = rootFiles;
91118         host.options = options;
91119         host.watchOptions = watchOptions;
91120         host.projectReferences = projectReferences;
91121         return host;
91122     }
91123     ts.createWatchCompilerHostOfFilesAndCompilerOptions = createWatchCompilerHostOfFilesAndCompilerOptions;
91124     function performIncrementalCompilation(input) {
91125         var system = input.system || ts.sys;
91126         var host = input.host || (input.host = ts.createIncrementalCompilerHost(input.options, system));
91127         var builderProgram = ts.createIncrementalProgram(input);
91128         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);
91129         if (input.afterProgramEmitAndDiagnostics)
91130             input.afterProgramEmitAndDiagnostics(builderProgram);
91131         return exitStatus;
91132     }
91133     ts.performIncrementalCompilation = performIncrementalCompilation;
91134 })(ts || (ts = {}));
91135 var ts;
91136 (function (ts) {
91137     function readBuilderProgram(compilerOptions, host) {
91138         if (ts.outFile(compilerOptions))
91139             return undefined;
91140         var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
91141         if (!buildInfoPath)
91142             return undefined;
91143         var content = host.readFile(buildInfoPath);
91144         if (!content)
91145             return undefined;
91146         var buildInfo = ts.getBuildInfo(content);
91147         if (buildInfo.version !== ts.version)
91148             return undefined;
91149         if (!buildInfo.program)
91150             return undefined;
91151         return ts.createBuildProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
91152     }
91153     ts.readBuilderProgram = readBuilderProgram;
91154     function createIncrementalCompilerHost(options, system) {
91155         if (system === void 0) { system = ts.sys; }
91156         var host = ts.createCompilerHostWorker(options, undefined, system);
91157         host.createHash = ts.maybeBind(system, system.createHash);
91158         ts.setGetSourceFileAsHashVersioned(host, system);
91159         ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
91160         return host;
91161     }
91162     ts.createIncrementalCompilerHost = createIncrementalCompilerHost;
91163     function createIncrementalProgram(_a) {
91164         var rootNames = _a.rootNames, options = _a.options, configFileParsingDiagnostics = _a.configFileParsingDiagnostics, projectReferences = _a.projectReferences, host = _a.host, createProgram = _a.createProgram;
91165         host = host || createIncrementalCompilerHost(options);
91166         createProgram = createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram;
91167         var oldProgram = readBuilderProgram(options, host);
91168         return createProgram(rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences);
91169     }
91170     ts.createIncrementalProgram = createIncrementalProgram;
91171     function createWatchCompilerHost(rootFilesOrConfigFileName, options, system, createProgram, reportDiagnostic, reportWatchStatus, projectReferencesOrWatchOptionsToExtend, watchOptionsOrExtraFileExtensions) {
91172         if (ts.isArray(rootFilesOrConfigFileName)) {
91173             return ts.createWatchCompilerHostOfFilesAndCompilerOptions({
91174                 rootFiles: rootFilesOrConfigFileName,
91175                 options: options,
91176                 watchOptions: watchOptionsOrExtraFileExtensions,
91177                 projectReferences: projectReferencesOrWatchOptionsToExtend,
91178                 system: system,
91179                 createProgram: createProgram,
91180                 reportDiagnostic: reportDiagnostic,
91181                 reportWatchStatus: reportWatchStatus,
91182             });
91183         }
91184         else {
91185             return ts.createWatchCompilerHostOfConfigFile({
91186                 configFileName: rootFilesOrConfigFileName,
91187                 optionsToExtend: options,
91188                 watchOptionsToExtend: projectReferencesOrWatchOptionsToExtend,
91189                 extraFileExtensions: watchOptionsOrExtraFileExtensions,
91190                 system: system,
91191                 createProgram: createProgram,
91192                 reportDiagnostic: reportDiagnostic,
91193                 reportWatchStatus: reportWatchStatus,
91194             });
91195         }
91196     }
91197     ts.createWatchCompilerHost = createWatchCompilerHost;
91198     function createWatchProgram(host) {
91199         var builderProgram;
91200         var reloadLevel;
91201         var missingFilesMap;
91202         var watchedWildcardDirectories;
91203         var timerToUpdateProgram;
91204         var timerToInvalidateFailedLookupResolutions;
91205         var sourceFilesCache = new ts.Map();
91206         var missingFilePathsRequestedForRelease;
91207         var hasChangedCompilerOptions = false;
91208         var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames();
91209         var currentDirectory = host.getCurrentDirectory();
91210         var configFileName = host.configFileName, _a = host.optionsToExtend, optionsToExtendForConfigFile = _a === void 0 ? {} : _a, watchOptionsToExtend = host.watchOptionsToExtend, extraFileExtensions = host.extraFileExtensions, createProgram = host.createProgram;
91211         var rootFileNames = host.rootFiles, compilerOptions = host.options, watchOptions = host.watchOptions, projectReferences = host.projectReferences;
91212         var configFileSpecs;
91213         var configFileParsingDiagnostics;
91214         var canConfigFileJsonReportNoInputFiles = false;
91215         var hasChangedConfigFileParsingErrors = false;
91216         var cachedDirectoryStructureHost = configFileName === undefined ? undefined : ts.createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensitiveFileNames);
91217         var directoryStructureHost = cachedDirectoryStructureHost || host;
91218         var parseConfigFileHost = ts.parseConfigHostFromCompilerHostLike(host, directoryStructureHost);
91219         var newLine = updateNewLine();
91220         if (configFileName && host.configFileParsingResult) {
91221             setConfigFileParsingResult(host.configFileParsingResult);
91222             newLine = updateNewLine();
91223         }
91224         reportWatchDiagnostic(ts.Diagnostics.Starting_compilation_in_watch_mode);
91225         if (configFileName && !host.configFileParsingResult) {
91226             newLine = ts.getNewLineCharacter(optionsToExtendForConfigFile, function () { return host.getNewLine(); });
91227             ts.Debug.assert(!rootFileNames);
91228             parseConfigFile();
91229             newLine = updateNewLine();
91230         }
91231         var _b = ts.createWatchFactory(host, compilerOptions), watchFile = _b.watchFile, watchFilePath = _b.watchFilePath, watchDirectory = _b.watchDirectory, writeLog = _b.writeLog;
91232         var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
91233         writeLog("Current directory: " + currentDirectory + " CaseSensitiveFileNames: " + useCaseSensitiveFileNames);
91234         var configFileWatcher;
91235         if (configFileName) {
91236             configFileWatcher = watchFile(host, configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile);
91237         }
91238         var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return compilerOptions; }, directoryStructureHost);
91239         ts.setGetSourceFileAsHashVersioned(compilerHost, host);
91240         var getNewSourceFile = compilerHost.getSourceFile;
91241         compilerHost.getSourceFile = function (fileName) {
91242             var args = [];
91243             for (var _i = 1; _i < arguments.length; _i++) {
91244                 args[_i - 1] = arguments[_i];
91245             }
91246             return getVersionedSourceFileByPath.apply(void 0, __spreadArrays([fileName, toPath(fileName)], args));
91247         };
91248         compilerHost.getSourceFileByPath = getVersionedSourceFileByPath;
91249         compilerHost.getNewLine = function () { return newLine; };
91250         compilerHost.fileExists = fileExists;
91251         compilerHost.onReleaseOldSourceFile = onReleaseOldSourceFile;
91252         compilerHost.toPath = toPath;
91253         compilerHost.getCompilationSettings = function () { return compilerOptions; };
91254         compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect);
91255         compilerHost.watchDirectoryOfFailedLookupLocation = function (dir, cb, flags) { return watchDirectory(host, dir, cb, flags, watchOptions, ts.WatchType.FailedLookupLocations); };
91256         compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(host, dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); };
91257         compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; };
91258         compilerHost.scheduleInvalidateResolutionsOfFailedLookupLocations = scheduleInvalidateResolutionsOfFailedLookupLocations;
91259         compilerHost.onInvalidatedResolution = scheduleProgramUpdate;
91260         compilerHost.onChangedAutomaticTypeDirectiveNames = scheduleProgramUpdate;
91261         compilerHost.fileIsOpen = ts.returnFalse;
91262         compilerHost.getCurrentProgram = getCurrentProgram;
91263         compilerHost.writeLog = writeLog;
91264         var resolutionCache = ts.createResolutionCache(compilerHost, configFileName ?
91265             ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFileName, currentDirectory)) :
91266             currentDirectory, false);
91267         compilerHost.resolveModuleNames = host.resolveModuleNames ?
91268             (function () {
91269                 var args = [];
91270                 for (var _i = 0; _i < arguments.length; _i++) {
91271                     args[_i] = arguments[_i];
91272                 }
91273                 return host.resolveModuleNames.apply(host, args);
91274             }) :
91275             (function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); });
91276         compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ?
91277             (function () {
91278                 var args = [];
91279                 for (var _i = 0; _i < arguments.length; _i++) {
91280                     args[_i] = arguments[_i];
91281                 }
91282                 return host.resolveTypeReferenceDirectives.apply(host, args);
91283             }) :
91284             (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); });
91285         var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
91286         builderProgram = readBuilderProgram(compilerOptions, compilerHost);
91287         synchronizeProgram();
91288         watchConfigFileWildCardDirectories();
91289         return configFileName ?
91290             { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, close: close } :
91291             { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, updateRootFileNames: updateRootFileNames, close: close };
91292         function close() {
91293             clearInvalidateResolutionsOfFailedLookupLocations();
91294             resolutionCache.clear();
91295             ts.clearMap(sourceFilesCache, function (value) {
91296                 if (value && value.fileWatcher) {
91297                     value.fileWatcher.close();
91298                     value.fileWatcher = undefined;
91299                 }
91300             });
91301             if (configFileWatcher) {
91302                 configFileWatcher.close();
91303                 configFileWatcher = undefined;
91304             }
91305             if (watchedWildcardDirectories) {
91306                 ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf);
91307                 watchedWildcardDirectories = undefined;
91308             }
91309             if (missingFilesMap) {
91310                 ts.clearMap(missingFilesMap, ts.closeFileWatcher);
91311                 missingFilesMap = undefined;
91312             }
91313         }
91314         function getCurrentBuilderProgram() {
91315             return builderProgram;
91316         }
91317         function getCurrentProgram() {
91318             return builderProgram && builderProgram.getProgramOrUndefined();
91319         }
91320         function synchronizeProgram() {
91321             writeLog("Synchronizing program");
91322             clearInvalidateResolutionsOfFailedLookupLocations();
91323             var program = getCurrentBuilderProgram();
91324             if (hasChangedCompilerOptions) {
91325                 newLine = updateNewLine();
91326                 if (program && ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) {
91327                     resolutionCache.clear();
91328                 }
91329             }
91330             var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
91331             if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences)) {
91332                 if (hasChangedConfigFileParsingErrors) {
91333                     builderProgram = createProgram(undefined, undefined, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
91334                     hasChangedConfigFileParsingErrors = false;
91335                 }
91336             }
91337             else {
91338                 createNewProgram(hasInvalidatedResolution);
91339             }
91340             if (host.afterProgramCreate && program !== builderProgram) {
91341                 host.afterProgramCreate(builderProgram);
91342             }
91343             return builderProgram;
91344         }
91345         function createNewProgram(hasInvalidatedResolution) {
91346             writeLog("CreatingProgramWith::");
91347             writeLog("  roots: " + JSON.stringify(rootFileNames));
91348             writeLog("  options: " + JSON.stringify(compilerOptions));
91349             var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram();
91350             hasChangedCompilerOptions = false;
91351             hasChangedConfigFileParsingErrors = false;
91352             resolutionCache.startCachingPerDirectoryResolution();
91353             compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
91354             compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
91355             builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
91356             resolutionCache.finishCachingPerDirectoryResolution();
91357             ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath);
91358             if (needsUpdateInTypeRootWatch) {
91359                 resolutionCache.updateTypeRootsWatch();
91360             }
91361             if (missingFilePathsRequestedForRelease) {
91362                 for (var _i = 0, missingFilePathsRequestedForRelease_1 = missingFilePathsRequestedForRelease; _i < missingFilePathsRequestedForRelease_1.length; _i++) {
91363                     var missingFilePath = missingFilePathsRequestedForRelease_1[_i];
91364                     if (!missingFilesMap.has(missingFilePath)) {
91365                         sourceFilesCache.delete(missingFilePath);
91366                     }
91367                 }
91368                 missingFilePathsRequestedForRelease = undefined;
91369             }
91370         }
91371         function updateRootFileNames(files) {
91372             ts.Debug.assert(!configFileName, "Cannot update root file names with config file watch mode");
91373             rootFileNames = files;
91374             scheduleProgramUpdate();
91375         }
91376         function updateNewLine() {
91377             return ts.getNewLineCharacter(compilerOptions || optionsToExtendForConfigFile, function () { return host.getNewLine(); });
91378         }
91379         function toPath(fileName) {
91380             return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
91381         }
91382         function isFileMissingOnHost(hostSourceFile) {
91383             return typeof hostSourceFile === "boolean";
91384         }
91385         function isFilePresenceUnknownOnHost(hostSourceFile) {
91386             return typeof hostSourceFile.version === "boolean";
91387         }
91388         function fileExists(fileName) {
91389             var path = toPath(fileName);
91390             if (isFileMissingOnHost(sourceFilesCache.get(path))) {
91391                 return false;
91392             }
91393             return directoryStructureHost.fileExists(fileName);
91394         }
91395         function getVersionedSourceFileByPath(fileName, path, languageVersion, onError, shouldCreateNewSourceFile) {
91396             var hostSourceFile = sourceFilesCache.get(path);
91397             if (isFileMissingOnHost(hostSourceFile)) {
91398                 return undefined;
91399             }
91400             if (hostSourceFile === undefined || shouldCreateNewSourceFile || isFilePresenceUnknownOnHost(hostSourceFile)) {
91401                 var sourceFile = getNewSourceFile(fileName, languageVersion, onError);
91402                 if (hostSourceFile) {
91403                     if (sourceFile) {
91404                         hostSourceFile.sourceFile = sourceFile;
91405                         hostSourceFile.version = sourceFile.version;
91406                         if (!hostSourceFile.fileWatcher) {
91407                             hostSourceFile.fileWatcher = watchFilePath(host, fileName, onSourceFileChange, ts.PollingInterval.Low, watchOptions, path, ts.WatchType.SourceFile);
91408                         }
91409                     }
91410                     else {
91411                         if (hostSourceFile.fileWatcher) {
91412                             hostSourceFile.fileWatcher.close();
91413                         }
91414                         sourceFilesCache.set(path, false);
91415                     }
91416                 }
91417                 else {
91418                     if (sourceFile) {
91419                         var fileWatcher = watchFilePath(host, fileName, onSourceFileChange, ts.PollingInterval.Low, watchOptions, path, ts.WatchType.SourceFile);
91420                         sourceFilesCache.set(path, { sourceFile: sourceFile, version: sourceFile.version, fileWatcher: fileWatcher });
91421                     }
91422                     else {
91423                         sourceFilesCache.set(path, false);
91424                     }
91425                 }
91426                 return sourceFile;
91427             }
91428             return hostSourceFile.sourceFile;
91429         }
91430         function nextSourceFileVersion(path) {
91431             var hostSourceFile = sourceFilesCache.get(path);
91432             if (hostSourceFile !== undefined) {
91433                 if (isFileMissingOnHost(hostSourceFile)) {
91434                     sourceFilesCache.set(path, { version: false });
91435                 }
91436                 else {
91437                     hostSourceFile.version = false;
91438                 }
91439             }
91440         }
91441         function getSourceVersion(path) {
91442             var hostSourceFile = sourceFilesCache.get(path);
91443             return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version;
91444         }
91445         function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) {
91446             var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath);
91447             if (hostSourceFileInfo !== undefined) {
91448                 if (isFileMissingOnHost(hostSourceFileInfo)) {
91449                     (missingFilePathsRequestedForRelease || (missingFilePathsRequestedForRelease = [])).push(oldSourceFile.path);
91450                 }
91451                 else if (hostSourceFileInfo.sourceFile === oldSourceFile) {
91452                     if (hostSourceFileInfo.fileWatcher) {
91453                         hostSourceFileInfo.fileWatcher.close();
91454                     }
91455                     sourceFilesCache.delete(oldSourceFile.resolvedPath);
91456                     if (!hasSourceFileByPath) {
91457                         resolutionCache.removeResolutionsOfFile(oldSourceFile.path);
91458                     }
91459                 }
91460             }
91461         }
91462         function reportWatchDiagnostic(message) {
91463             if (host.onWatchStatusChange) {
91464                 host.onWatchStatusChange(ts.createCompilerDiagnostic(message), newLine, compilerOptions || optionsToExtendForConfigFile);
91465             }
91466         }
91467         function hasChangedAutomaticTypeDirectiveNames() {
91468             return resolutionCache.hasChangedAutomaticTypeDirectiveNames();
91469         }
91470         function clearInvalidateResolutionsOfFailedLookupLocations() {
91471             if (!timerToInvalidateFailedLookupResolutions)
91472                 return false;
91473             host.clearTimeout(timerToInvalidateFailedLookupResolutions);
91474             timerToInvalidateFailedLookupResolutions = undefined;
91475             return true;
91476         }
91477         function scheduleInvalidateResolutionsOfFailedLookupLocations() {
91478             if (!host.setTimeout || !host.clearTimeout) {
91479                 return resolutionCache.invalidateResolutionsOfFailedLookupLocations();
91480             }
91481             var pending = clearInvalidateResolutionsOfFailedLookupLocations();
91482             writeLog("Scheduling invalidateFailedLookup" + (pending ? ", Cancelled earlier one" : ""));
91483             timerToInvalidateFailedLookupResolutions = host.setTimeout(invalidateResolutionsOfFailedLookup, 250);
91484         }
91485         function invalidateResolutionsOfFailedLookup() {
91486             timerToInvalidateFailedLookupResolutions = undefined;
91487             if (resolutionCache.invalidateResolutionsOfFailedLookupLocations()) {
91488                 scheduleProgramUpdate();
91489             }
91490         }
91491         function scheduleProgramUpdate() {
91492             if (!host.setTimeout || !host.clearTimeout) {
91493                 return;
91494             }
91495             if (timerToUpdateProgram) {
91496                 host.clearTimeout(timerToUpdateProgram);
91497             }
91498             writeLog("Scheduling update");
91499             timerToUpdateProgram = host.setTimeout(updateProgramWithWatchStatus, 250);
91500         }
91501         function scheduleProgramReload() {
91502             ts.Debug.assert(!!configFileName);
91503             reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
91504             scheduleProgramUpdate();
91505         }
91506         function updateProgramWithWatchStatus() {
91507             timerToUpdateProgram = undefined;
91508             reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
91509             updateProgram();
91510         }
91511         function updateProgram() {
91512             switch (reloadLevel) {
91513                 case ts.ConfigFileProgramReloadLevel.Partial:
91514                     ts.perfLogger.logStartUpdateProgram("PartialConfigReload");
91515                     reloadFileNamesFromConfigFile();
91516                     break;
91517                 case ts.ConfigFileProgramReloadLevel.Full:
91518                     ts.perfLogger.logStartUpdateProgram("FullConfigReload");
91519                     reloadConfigFile();
91520                     break;
91521                 default:
91522                     ts.perfLogger.logStartUpdateProgram("SynchronizeProgram");
91523                     synchronizeProgram();
91524                     break;
91525             }
91526             ts.perfLogger.logStopUpdateProgram("Done");
91527             return getCurrentBuilderProgram();
91528         }
91529         function reloadFileNamesFromConfigFile() {
91530             writeLog("Reloading new file names and options");
91531             var result = ts.getFileNamesFromConfigSpecs(configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions);
91532             if (ts.updateErrorForNoInputFiles(result, ts.getNormalizedAbsolutePath(configFileName, currentDirectory), configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) {
91533                 hasChangedConfigFileParsingErrors = true;
91534             }
91535             rootFileNames = result.fileNames;
91536             synchronizeProgram();
91537         }
91538         function reloadConfigFile() {
91539             writeLog("Reloading config file: " + configFileName);
91540             reloadLevel = ts.ConfigFileProgramReloadLevel.None;
91541             if (cachedDirectoryStructureHost) {
91542                 cachedDirectoryStructureHost.clearCache();
91543             }
91544             parseConfigFile();
91545             hasChangedCompilerOptions = true;
91546             synchronizeProgram();
91547             watchConfigFileWildCardDirectories();
91548         }
91549         function parseConfigFile() {
91550             setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost, undefined, watchOptionsToExtend, extraFileExtensions));
91551         }
91552         function setConfigFileParsingResult(configFileParseResult) {
91553             rootFileNames = configFileParseResult.fileNames;
91554             compilerOptions = configFileParseResult.options;
91555             watchOptions = configFileParseResult.watchOptions;
91556             configFileSpecs = configFileParseResult.configFileSpecs;
91557             projectReferences = configFileParseResult.projectReferences;
91558             configFileParsingDiagnostics = ts.getConfigFileParsingDiagnostics(configFileParseResult).slice();
91559             canConfigFileJsonReportNoInputFiles = ts.canJsonReportNoInputFiles(configFileParseResult.raw);
91560             hasChangedConfigFileParsingErrors = true;
91561         }
91562         function onSourceFileChange(fileName, eventKind, path) {
91563             updateCachedSystemWithFile(fileName, path, eventKind);
91564             if (eventKind === ts.FileWatcherEventKind.Deleted && sourceFilesCache.has(path)) {
91565                 resolutionCache.invalidateResolutionOfFile(path);
91566             }
91567             resolutionCache.removeResolutionsFromProjectReferenceRedirects(path);
91568             nextSourceFileVersion(path);
91569             scheduleProgramUpdate();
91570         }
91571         function updateCachedSystemWithFile(fileName, path, eventKind) {
91572             if (cachedDirectoryStructureHost) {
91573                 cachedDirectoryStructureHost.addOrDeleteFile(fileName, path, eventKind);
91574             }
91575         }
91576         function watchMissingFilePath(missingFilePath) {
91577             return watchFilePath(host, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, missingFilePath, ts.WatchType.MissingFile);
91578         }
91579         function onMissingFileChange(fileName, eventKind, missingFilePath) {
91580             updateCachedSystemWithFile(fileName, missingFilePath, eventKind);
91581             if (eventKind === ts.FileWatcherEventKind.Created && missingFilesMap.has(missingFilePath)) {
91582                 missingFilesMap.get(missingFilePath).close();
91583                 missingFilesMap.delete(missingFilePath);
91584                 nextSourceFileVersion(missingFilePath);
91585                 scheduleProgramUpdate();
91586             }
91587         }
91588         function watchConfigFileWildCardDirectories() {
91589             if (configFileSpecs) {
91590                 ts.updateWatchingWildcardDirectories(watchedWildcardDirectories || (watchedWildcardDirectories = new ts.Map()), new ts.Map(ts.getEntries(configFileSpecs.wildcardDirectories)), watchWildcardDirectory);
91591             }
91592             else if (watchedWildcardDirectories) {
91593                 ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf);
91594             }
91595         }
91596         function watchWildcardDirectory(directory, flags) {
91597             return watchDirectory(host, directory, function (fileOrDirectory) {
91598                 ts.Debug.assert(!!configFileName);
91599                 var fileOrDirectoryPath = toPath(fileOrDirectory);
91600                 if (cachedDirectoryStructureHost) {
91601                     cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
91602                 }
91603                 nextSourceFileVersion(fileOrDirectoryPath);
91604                 if (ts.isIgnoredFileFromWildCardWatching({
91605                     watchedDirPath: toPath(directory),
91606                     fileOrDirectory: fileOrDirectory,
91607                     fileOrDirectoryPath: fileOrDirectoryPath,
91608                     configFileName: configFileName,
91609                     configFileSpecs: configFileSpecs,
91610                     extraFileExtensions: extraFileExtensions,
91611                     options: compilerOptions,
91612                     program: getCurrentBuilderProgram(),
91613                     currentDirectory: currentDirectory,
91614                     useCaseSensitiveFileNames: useCaseSensitiveFileNames,
91615                     writeLog: writeLog
91616                 }))
91617                     return;
91618                 if (reloadLevel !== ts.ConfigFileProgramReloadLevel.Full) {
91619                     reloadLevel = ts.ConfigFileProgramReloadLevel.Partial;
91620                     scheduleProgramUpdate();
91621                 }
91622             }, flags, watchOptions, ts.WatchType.WildcardDirectory);
91623         }
91624     }
91625     ts.createWatchProgram = createWatchProgram;
91626 })(ts || (ts = {}));
91627 var ts;
91628 (function (ts) {
91629     var UpToDateStatusType;
91630     (function (UpToDateStatusType) {
91631         UpToDateStatusType[UpToDateStatusType["Unbuildable"] = 0] = "Unbuildable";
91632         UpToDateStatusType[UpToDateStatusType["UpToDate"] = 1] = "UpToDate";
91633         UpToDateStatusType[UpToDateStatusType["UpToDateWithUpstreamTypes"] = 2] = "UpToDateWithUpstreamTypes";
91634         UpToDateStatusType[UpToDateStatusType["OutOfDateWithPrepend"] = 3] = "OutOfDateWithPrepend";
91635         UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing";
91636         UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf";
91637         UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream";
91638         UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 7] = "UpstreamOutOfDate";
91639         UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 8] = "UpstreamBlocked";
91640         UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 9] = "ComputingUpstream";
91641         UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 10] = "TsVersionOutputOfDate";
91642         UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 11] = "ContainerOnly";
91643     })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {}));
91644     function resolveConfigFileProjectName(project) {
91645         if (ts.fileExtensionIs(project, ".json")) {
91646             return project;
91647         }
91648         return ts.combinePaths(project, "tsconfig.json");
91649     }
91650     ts.resolveConfigFileProjectName = resolveConfigFileProjectName;
91651 })(ts || (ts = {}));
91652 var ts;
91653 (function (ts) {
91654     var minimumDate = new Date(-8640000000000000);
91655     var maximumDate = new Date(8640000000000000);
91656     var BuildResultFlags;
91657     (function (BuildResultFlags) {
91658         BuildResultFlags[BuildResultFlags["None"] = 0] = "None";
91659         BuildResultFlags[BuildResultFlags["Success"] = 1] = "Success";
91660         BuildResultFlags[BuildResultFlags["DeclarationOutputUnchanged"] = 2] = "DeclarationOutputUnchanged";
91661         BuildResultFlags[BuildResultFlags["ConfigFileErrors"] = 4] = "ConfigFileErrors";
91662         BuildResultFlags[BuildResultFlags["SyntaxErrors"] = 8] = "SyntaxErrors";
91663         BuildResultFlags[BuildResultFlags["TypeErrors"] = 16] = "TypeErrors";
91664         BuildResultFlags[BuildResultFlags["DeclarationEmitErrors"] = 32] = "DeclarationEmitErrors";
91665         BuildResultFlags[BuildResultFlags["EmitErrors"] = 64] = "EmitErrors";
91666         BuildResultFlags[BuildResultFlags["AnyErrors"] = 124] = "AnyErrors";
91667     })(BuildResultFlags || (BuildResultFlags = {}));
91668     function getOrCreateValueFromConfigFileMap(configFileMap, resolved, createT) {
91669         var existingValue = configFileMap.get(resolved);
91670         var newValue;
91671         if (!existingValue) {
91672             newValue = createT();
91673             configFileMap.set(resolved, newValue);
91674         }
91675         return existingValue || newValue;
91676     }
91677     function getOrCreateValueMapFromConfigFileMap(configFileMap, resolved) {
91678         return getOrCreateValueFromConfigFileMap(configFileMap, resolved, function () { return new ts.Map(); });
91679     }
91680     function newer(date1, date2) {
91681         return date2 > date1 ? date2 : date1;
91682     }
91683     function isDeclarationFile(fileName) {
91684         return ts.fileExtensionIs(fileName, ".d.ts");
91685     }
91686     function isCircularBuildOrder(buildOrder) {
91687         return !!buildOrder && !!buildOrder.buildOrder;
91688     }
91689     ts.isCircularBuildOrder = isCircularBuildOrder;
91690     function getBuildOrderFromAnyBuildOrder(anyBuildOrder) {
91691         return isCircularBuildOrder(anyBuildOrder) ? anyBuildOrder.buildOrder : anyBuildOrder;
91692     }
91693     ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder;
91694     function createBuilderStatusReporter(system, pretty) {
91695         return function (diagnostic) {
91696             var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - ";
91697             output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine);
91698             system.write(output);
91699         };
91700     }
91701     ts.createBuilderStatusReporter = createBuilderStatusReporter;
91702     function createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus) {
91703         var host = ts.createProgramHost(system, createProgram);
91704         host.getModifiedTime = system.getModifiedTime ? function (path) { return system.getModifiedTime(path); } : ts.returnUndefined;
91705         host.setModifiedTime = system.setModifiedTime ? function (path, date) { return system.setModifiedTime(path, date); } : ts.noop;
91706         host.deleteFile = system.deleteFile ? function (path) { return system.deleteFile(path); } : ts.noop;
91707         host.reportDiagnostic = reportDiagnostic || ts.createDiagnosticReporter(system);
91708         host.reportSolutionBuilderStatus = reportSolutionBuilderStatus || createBuilderStatusReporter(system);
91709         host.now = ts.maybeBind(system, system.now);
91710         return host;
91711     }
91712     function createSolutionBuilderHost(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus, reportErrorSummary) {
91713         if (system === void 0) { system = ts.sys; }
91714         var host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus);
91715         host.reportErrorSummary = reportErrorSummary;
91716         return host;
91717     }
91718     ts.createSolutionBuilderHost = createSolutionBuilderHost;
91719     function createSolutionBuilderWithWatchHost(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus, reportWatchStatus) {
91720         if (system === void 0) { system = ts.sys; }
91721         var host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus);
91722         var watchHost = ts.createWatchHost(system, reportWatchStatus);
91723         ts.copyProperties(host, watchHost);
91724         return host;
91725     }
91726     ts.createSolutionBuilderWithWatchHost = createSolutionBuilderWithWatchHost;
91727     function getCompilerOptionsOfBuildOptions(buildOptions) {
91728         var result = {};
91729         ts.commonOptionsWithBuild.forEach(function (option) {
91730             if (ts.hasProperty(buildOptions, option.name))
91731                 result[option.name] = buildOptions[option.name];
91732         });
91733         return result;
91734     }
91735     function createSolutionBuilder(host, rootNames, defaultOptions) {
91736         return createSolutionBuilderWorker(false, host, rootNames, defaultOptions);
91737     }
91738     ts.createSolutionBuilder = createSolutionBuilder;
91739     function createSolutionBuilderWithWatch(host, rootNames, defaultOptions, baseWatchOptions) {
91740         return createSolutionBuilderWorker(true, host, rootNames, defaultOptions, baseWatchOptions);
91741     }
91742     ts.createSolutionBuilderWithWatch = createSolutionBuilderWithWatch;
91743     function createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions) {
91744         var host = hostOrHostWithWatch;
91745         var hostWithWatch = hostOrHostWithWatch;
91746         var currentDirectory = host.getCurrentDirectory();
91747         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
91748         var baseCompilerOptions = getCompilerOptionsOfBuildOptions(options);
91749         var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return state.projectCompilerOptions; });
91750         ts.setGetSourceFileAsHashVersioned(compilerHost, host);
91751         compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); };
91752         compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames);
91753         compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives);
91754         var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
91755         if (!compilerHost.resolveModuleNames) {
91756             var loader_3 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule; };
91757             compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference) {
91758                 return ts.loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_3);
91759             };
91760         }
91761         var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchFilePath = _a.watchFilePath, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
91762         var state = {
91763             host: host,
91764             hostWithWatch: hostWithWatch,
91765             currentDirectory: currentDirectory,
91766             getCanonicalFileName: getCanonicalFileName,
91767             parseConfigFileHost: ts.parseConfigHostFromCompilerHostLike(host),
91768             writeFileName: host.trace ? function (s) { return host.trace(s); } : undefined,
91769             options: options,
91770             baseCompilerOptions: baseCompilerOptions,
91771             rootNames: rootNames,
91772             baseWatchOptions: baseWatchOptions,
91773             resolvedConfigFilePaths: new ts.Map(),
91774             configFileCache: new ts.Map(),
91775             projectStatus: new ts.Map(),
91776             buildInfoChecked: new ts.Map(),
91777             extendedConfigCache: new ts.Map(),
91778             builderPrograms: new ts.Map(),
91779             diagnostics: new ts.Map(),
91780             projectPendingBuild: new ts.Map(),
91781             projectErrorsReported: new ts.Map(),
91782             compilerHost: compilerHost,
91783             moduleResolutionCache: moduleResolutionCache,
91784             buildOrder: undefined,
91785             readFileWithCache: function (f) { return host.readFile(f); },
91786             projectCompilerOptions: baseCompilerOptions,
91787             cache: undefined,
91788             allProjectBuildPending: true,
91789             needsSummary: true,
91790             watchAllProjectsPending: watch,
91791             currentInvalidatedProject: undefined,
91792             watch: watch,
91793             allWatchedWildcardDirectories: new ts.Map(),
91794             allWatchedInputFiles: new ts.Map(),
91795             allWatchedConfigFiles: new ts.Map(),
91796             timerToBuildInvalidatedProject: undefined,
91797             reportFileChangeDetected: false,
91798             watchFile: watchFile,
91799             watchFilePath: watchFilePath,
91800             watchDirectory: watchDirectory,
91801             writeLog: writeLog,
91802         };
91803         return state;
91804     }
91805     function toPath(state, fileName) {
91806         return ts.toPath(fileName, state.currentDirectory, state.getCanonicalFileName);
91807     }
91808     function toResolvedConfigFilePath(state, fileName) {
91809         var resolvedConfigFilePaths = state.resolvedConfigFilePaths;
91810         var path = resolvedConfigFilePaths.get(fileName);
91811         if (path !== undefined)
91812             return path;
91813         var resolvedPath = toPath(state, fileName);
91814         resolvedConfigFilePaths.set(fileName, resolvedPath);
91815         return resolvedPath;
91816     }
91817     function isParsedCommandLine(entry) {
91818         return !!entry.options;
91819     }
91820     function parseConfigFile(state, configFileName, configFilePath) {
91821         var configFileCache = state.configFileCache;
91822         var value = configFileCache.get(configFilePath);
91823         if (value) {
91824             return isParsedCommandLine(value) ? value : undefined;
91825         }
91826         var diagnostic;
91827         var parseConfigFileHost = state.parseConfigFileHost, baseCompilerOptions = state.baseCompilerOptions, baseWatchOptions = state.baseWatchOptions, extendedConfigCache = state.extendedConfigCache, host = state.host;
91828         var parsed;
91829         if (host.getParsedCommandLine) {
91830             parsed = host.getParsedCommandLine(configFileName);
91831             if (!parsed)
91832                 diagnostic = ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, configFileName);
91833         }
91834         else {
91835             parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = function (d) { return diagnostic = d; };
91836             parsed = ts.getParsedCommandLineOfConfigFile(configFileName, baseCompilerOptions, parseConfigFileHost, extendedConfigCache, baseWatchOptions);
91837             parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = ts.noop;
91838         }
91839         configFileCache.set(configFilePath, parsed || diagnostic);
91840         return parsed;
91841     }
91842     function resolveProjectName(state, name) {
91843         return ts.resolveConfigFileProjectName(ts.resolvePath(state.currentDirectory, name));
91844     }
91845     function createBuildOrder(state, roots) {
91846         var temporaryMarks = new ts.Map();
91847         var permanentMarks = new ts.Map();
91848         var circularityReportStack = [];
91849         var buildOrder;
91850         var circularDiagnostics;
91851         for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) {
91852             var root = roots_1[_i];
91853             visit(root);
91854         }
91855         return circularDiagnostics ?
91856             { buildOrder: buildOrder || ts.emptyArray, circularDiagnostics: circularDiagnostics } :
91857             buildOrder || ts.emptyArray;
91858         function visit(configFileName, inCircularContext) {
91859             var projPath = toResolvedConfigFilePath(state, configFileName);
91860             if (permanentMarks.has(projPath))
91861                 return;
91862             if (temporaryMarks.has(projPath)) {
91863                 if (!inCircularContext) {
91864                     (circularDiagnostics || (circularDiagnostics = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n")));
91865                 }
91866                 return;
91867             }
91868             temporaryMarks.set(projPath, true);
91869             circularityReportStack.push(configFileName);
91870             var parsed = parseConfigFile(state, configFileName, projPath);
91871             if (parsed && parsed.projectReferences) {
91872                 for (var _i = 0, _a = parsed.projectReferences; _i < _a.length; _i++) {
91873                     var ref = _a[_i];
91874                     var resolvedRefPath = resolveProjectName(state, ref.path);
91875                     visit(resolvedRefPath, inCircularContext || ref.circular);
91876                 }
91877             }
91878             circularityReportStack.pop();
91879             permanentMarks.set(projPath, true);
91880             (buildOrder || (buildOrder = [])).push(configFileName);
91881         }
91882     }
91883     function getBuildOrder(state) {
91884         return state.buildOrder || createStateBuildOrder(state);
91885     }
91886     function createStateBuildOrder(state) {
91887         var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }));
91888         state.resolvedConfigFilePaths.clear();
91889         var currentProjects = new ts.Map(getBuildOrderFromAnyBuildOrder(buildOrder).map(function (resolved) { return [toResolvedConfigFilePath(state, resolved), true]; }));
91890         var noopOnDelete = { onDeleteValue: ts.noop };
91891         ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete);
91892         ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete);
91893         ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete);
91894         ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete);
91895         ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete);
91896         ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete);
91897         ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete);
91898         if (state.watch) {
91899             ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher });
91900             ts.mutateMapSkippingNewValues(state.allWatchedWildcardDirectories, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcherOf); } });
91901             ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } });
91902         }
91903         return state.buildOrder = buildOrder;
91904     }
91905     function getBuildOrderFor(state, project, onlyReferences) {
91906         var resolvedProject = project && resolveProjectName(state, project);
91907         var buildOrderFromState = getBuildOrder(state);
91908         if (isCircularBuildOrder(buildOrderFromState))
91909             return buildOrderFromState;
91910         if (resolvedProject) {
91911             var projectPath_1 = toResolvedConfigFilePath(state, resolvedProject);
91912             var projectIndex = ts.findIndex(buildOrderFromState, function (configFileName) { return toResolvedConfigFilePath(state, configFileName) === projectPath_1; });
91913             if (projectIndex === -1)
91914                 return undefined;
91915         }
91916         var buildOrder = resolvedProject ? createBuildOrder(state, [resolvedProject]) : buildOrderFromState;
91917         ts.Debug.assert(!isCircularBuildOrder(buildOrder));
91918         ts.Debug.assert(!onlyReferences || resolvedProject !== undefined);
91919         ts.Debug.assert(!onlyReferences || buildOrder[buildOrder.length - 1] === resolvedProject);
91920         return onlyReferences ? buildOrder.slice(0, buildOrder.length - 1) : buildOrder;
91921     }
91922     function enableCache(state) {
91923         if (state.cache) {
91924             disableCache(state);
91925         }
91926         var compilerHost = state.compilerHost, host = state.host;
91927         var originalReadFileWithCache = state.readFileWithCache;
91928         var originalGetSourceFile = compilerHost.getSourceFile;
91929         var _a = ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return toPath(state, fileName); }, function () {
91930             var args = [];
91931             for (var _i = 0; _i < arguments.length; _i++) {
91932                 args[_i] = arguments[_i];
91933             }
91934             return originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args));
91935         }), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, getSourceFileWithCache = _a.getSourceFileWithCache, readFileWithCache = _a.readFileWithCache;
91936         state.readFileWithCache = readFileWithCache;
91937         compilerHost.getSourceFile = getSourceFileWithCache;
91938         state.cache = {
91939             originalReadFile: originalReadFile,
91940             originalFileExists: originalFileExists,
91941             originalDirectoryExists: originalDirectoryExists,
91942             originalCreateDirectory: originalCreateDirectory,
91943             originalWriteFile: originalWriteFile,
91944             originalReadFileWithCache: originalReadFileWithCache,
91945             originalGetSourceFile: originalGetSourceFile,
91946         };
91947     }
91948     function disableCache(state) {
91949         if (!state.cache)
91950             return;
91951         var cache = state.cache, host = state.host, compilerHost = state.compilerHost, extendedConfigCache = state.extendedConfigCache, moduleResolutionCache = state.moduleResolutionCache;
91952         host.readFile = cache.originalReadFile;
91953         host.fileExists = cache.originalFileExists;
91954         host.directoryExists = cache.originalDirectoryExists;
91955         host.createDirectory = cache.originalCreateDirectory;
91956         host.writeFile = cache.originalWriteFile;
91957         compilerHost.getSourceFile = cache.originalGetSourceFile;
91958         state.readFileWithCache = cache.originalReadFileWithCache;
91959         extendedConfigCache.clear();
91960         if (moduleResolutionCache) {
91961             moduleResolutionCache.directoryToModuleNameMap.clear();
91962             moduleResolutionCache.moduleNameToDirectoryMap.clear();
91963         }
91964         state.cache = undefined;
91965     }
91966     function clearProjectStatus(state, resolved) {
91967         state.projectStatus.delete(resolved);
91968         state.diagnostics.delete(resolved);
91969     }
91970     function addProjToQueue(_a, proj, reloadLevel) {
91971         var projectPendingBuild = _a.projectPendingBuild;
91972         var value = projectPendingBuild.get(proj);
91973         if (value === undefined) {
91974             projectPendingBuild.set(proj, reloadLevel);
91975         }
91976         else if (value < reloadLevel) {
91977             projectPendingBuild.set(proj, reloadLevel);
91978         }
91979     }
91980     function setupInitialBuild(state, cancellationToken) {
91981         if (!state.allProjectBuildPending)
91982             return;
91983         state.allProjectBuildPending = false;
91984         if (state.options.watch) {
91985             reportWatchStatus(state, ts.Diagnostics.Starting_compilation_in_watch_mode);
91986         }
91987         enableCache(state);
91988         var buildOrder = getBuildOrderFromAnyBuildOrder(getBuildOrder(state));
91989         buildOrder.forEach(function (configFileName) {
91990             return state.projectPendingBuild.set(toResolvedConfigFilePath(state, configFileName), ts.ConfigFileProgramReloadLevel.None);
91991         });
91992         if (cancellationToken) {
91993             cancellationToken.throwIfCancellationRequested();
91994         }
91995     }
91996     var InvalidatedProjectKind;
91997     (function (InvalidatedProjectKind) {
91998         InvalidatedProjectKind[InvalidatedProjectKind["Build"] = 0] = "Build";
91999         InvalidatedProjectKind[InvalidatedProjectKind["UpdateBundle"] = 1] = "UpdateBundle";
92000         InvalidatedProjectKind[InvalidatedProjectKind["UpdateOutputFileStamps"] = 2] = "UpdateOutputFileStamps";
92001     })(InvalidatedProjectKind = ts.InvalidatedProjectKind || (ts.InvalidatedProjectKind = {}));
92002     function doneInvalidatedProject(state, projectPath) {
92003         state.projectPendingBuild.delete(projectPath);
92004         state.currentInvalidatedProject = undefined;
92005         return state.diagnostics.has(projectPath) ?
92006             ts.ExitStatus.DiagnosticsPresent_OutputsSkipped :
92007             ts.ExitStatus.Success;
92008     }
92009     function createUpdateOutputFileStampsProject(state, project, projectPath, config, buildOrder) {
92010         var updateOutputFileStampsPending = true;
92011         return {
92012             kind: InvalidatedProjectKind.UpdateOutputFileStamps,
92013             project: project,
92014             projectPath: projectPath,
92015             buildOrder: buildOrder,
92016             getCompilerOptions: function () { return config.options; },
92017             getCurrentDirectory: function () { return state.currentDirectory; },
92018             updateOutputFileStatmps: function () {
92019                 updateOutputTimestamps(state, config, projectPath);
92020                 updateOutputFileStampsPending = false;
92021             },
92022             done: function () {
92023                 if (updateOutputFileStampsPending) {
92024                     updateOutputTimestamps(state, config, projectPath);
92025                 }
92026                 return doneInvalidatedProject(state, projectPath);
92027             }
92028         };
92029     }
92030     var BuildStep;
92031     (function (BuildStep) {
92032         BuildStep[BuildStep["CreateProgram"] = 0] = "CreateProgram";
92033         BuildStep[BuildStep["SyntaxDiagnostics"] = 1] = "SyntaxDiagnostics";
92034         BuildStep[BuildStep["SemanticDiagnostics"] = 2] = "SemanticDiagnostics";
92035         BuildStep[BuildStep["Emit"] = 3] = "Emit";
92036         BuildStep[BuildStep["EmitBundle"] = 4] = "EmitBundle";
92037         BuildStep[BuildStep["EmitBuildInfo"] = 5] = "EmitBuildInfo";
92038         BuildStep[BuildStep["BuildInvalidatedProjectOfBundle"] = 6] = "BuildInvalidatedProjectOfBundle";
92039         BuildStep[BuildStep["QueueReferencingProjects"] = 7] = "QueueReferencingProjects";
92040         BuildStep[BuildStep["Done"] = 8] = "Done";
92041     })(BuildStep || (BuildStep = {}));
92042     function createBuildOrUpdateInvalidedProject(kind, state, project, projectPath, projectIndex, config, buildOrder) {
92043         var step = kind === InvalidatedProjectKind.Build ? BuildStep.CreateProgram : BuildStep.EmitBundle;
92044         var program;
92045         var buildResult;
92046         var invalidatedProjectOfBundle;
92047         return kind === InvalidatedProjectKind.Build ?
92048             {
92049                 kind: kind,
92050                 project: project,
92051                 projectPath: projectPath,
92052                 buildOrder: buildOrder,
92053                 getCompilerOptions: function () { return config.options; },
92054                 getCurrentDirectory: function () { return state.currentDirectory; },
92055                 getBuilderProgram: function () { return withProgramOrUndefined(ts.identity); },
92056                 getProgram: function () {
92057                     return withProgramOrUndefined(function (program) { return program.getProgramOrUndefined(); });
92058                 },
92059                 getSourceFile: function (fileName) {
92060                     return withProgramOrUndefined(function (program) { return program.getSourceFile(fileName); });
92061                 },
92062                 getSourceFiles: function () {
92063                     return withProgramOrEmptyArray(function (program) { return program.getSourceFiles(); });
92064                 },
92065                 getOptionsDiagnostics: function (cancellationToken) {
92066                     return withProgramOrEmptyArray(function (program) { return program.getOptionsDiagnostics(cancellationToken); });
92067                 },
92068                 getGlobalDiagnostics: function (cancellationToken) {
92069                     return withProgramOrEmptyArray(function (program) { return program.getGlobalDiagnostics(cancellationToken); });
92070                 },
92071                 getConfigFileParsingDiagnostics: function () {
92072                     return withProgramOrEmptyArray(function (program) { return program.getConfigFileParsingDiagnostics(); });
92073                 },
92074                 getSyntacticDiagnostics: function (sourceFile, cancellationToken) {
92075                     return withProgramOrEmptyArray(function (program) { return program.getSyntacticDiagnostics(sourceFile, cancellationToken); });
92076                 },
92077                 getAllDependencies: function (sourceFile) {
92078                     return withProgramOrEmptyArray(function (program) { return program.getAllDependencies(sourceFile); });
92079                 },
92080                 getSemanticDiagnostics: function (sourceFile, cancellationToken) {
92081                     return withProgramOrEmptyArray(function (program) { return program.getSemanticDiagnostics(sourceFile, cancellationToken); });
92082                 },
92083                 getSemanticDiagnosticsOfNextAffectedFile: function (cancellationToken, ignoreSourceFile) {
92084                     return withProgramOrUndefined(function (program) {
92085                         return (program.getSemanticDiagnosticsOfNextAffectedFile) &&
92086                             program.getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile);
92087                     });
92088                 },
92089                 emit: function (targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
92090                     if (targetSourceFile || emitOnlyDtsFiles) {
92091                         return withProgramOrUndefined(function (program) { return program.emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); });
92092                     }
92093                     executeSteps(BuildStep.SemanticDiagnostics, cancellationToken);
92094                     if (step === BuildStep.EmitBuildInfo) {
92095                         return emitBuildInfo(writeFile, cancellationToken);
92096                     }
92097                     if (step !== BuildStep.Emit)
92098                         return undefined;
92099                     return emit(writeFile, cancellationToken, customTransformers);
92100                 },
92101                 done: done
92102             } :
92103             {
92104                 kind: kind,
92105                 project: project,
92106                 projectPath: projectPath,
92107                 buildOrder: buildOrder,
92108                 getCompilerOptions: function () { return config.options; },
92109                 getCurrentDirectory: function () { return state.currentDirectory; },
92110                 emit: function (writeFile, customTransformers) {
92111                     if (step !== BuildStep.EmitBundle)
92112                         return invalidatedProjectOfBundle;
92113                     return emitBundle(writeFile, customTransformers);
92114                 },
92115                 done: done,
92116             };
92117         function done(cancellationToken, writeFile, customTransformers) {
92118             executeSteps(BuildStep.Done, cancellationToken, writeFile, customTransformers);
92119             return doneInvalidatedProject(state, projectPath);
92120         }
92121         function withProgramOrUndefined(action) {
92122             executeSteps(BuildStep.CreateProgram);
92123             return program && action(program);
92124         }
92125         function withProgramOrEmptyArray(action) {
92126             return withProgramOrUndefined(action) || ts.emptyArray;
92127         }
92128         function createProgram() {
92129             ts.Debug.assert(program === undefined);
92130             if (state.options.dry) {
92131                 reportStatus(state, ts.Diagnostics.A_non_dry_build_would_build_project_0, project);
92132                 buildResult = BuildResultFlags.Success;
92133                 step = BuildStep.QueueReferencingProjects;
92134                 return;
92135             }
92136             if (state.options.verbose)
92137                 reportStatus(state, ts.Diagnostics.Building_project_0, project);
92138             if (config.fileNames.length === 0) {
92139                 reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
92140                 buildResult = BuildResultFlags.None;
92141                 step = BuildStep.QueueReferencingProjects;
92142                 return;
92143             }
92144             var host = state.host, compilerHost = state.compilerHost;
92145             state.projectCompilerOptions = config.options;
92146             updateModuleResolutionCache(state, project, config);
92147             program = host.createProgram(config.fileNames, config.options, compilerHost, getOldProgram(state, projectPath, config), ts.getConfigFileParsingDiagnostics(config), config.projectReferences);
92148             if (state.watch) {
92149                 state.builderPrograms.set(projectPath, program);
92150             }
92151             step++;
92152         }
92153         function handleDiagnostics(diagnostics, errorFlags, errorType) {
92154             var _a;
92155             if (diagnostics.length) {
92156                 (_a = buildErrors(state, projectPath, program, config, diagnostics, errorFlags, errorType), buildResult = _a.buildResult, step = _a.step);
92157             }
92158             else {
92159                 step++;
92160             }
92161         }
92162         function getSyntaxDiagnostics(cancellationToken) {
92163             ts.Debug.assertIsDefined(program);
92164             handleDiagnostics(__spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic");
92165         }
92166         function getSemanticDiagnostics(cancellationToken) {
92167             handleDiagnostics(ts.Debug.checkDefined(program).getSemanticDiagnostics(undefined, cancellationToken), BuildResultFlags.TypeErrors, "Semantic");
92168         }
92169         function emit(writeFileCallback, cancellationToken, customTransformers) {
92170             var _a;
92171             ts.Debug.assertIsDefined(program);
92172             ts.Debug.assert(step === BuildStep.Emit);
92173             program.backupState();
92174             var declDiagnostics;
92175             var reportDeclarationDiagnostics = function (d) { return (declDiagnostics || (declDiagnostics = [])).push(d); };
92176             var outputFiles = [];
92177             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;
92178             if (declDiagnostics) {
92179                 program.restoreState();
92180                 (_a = buildErrors(state, projectPath, program, config, declDiagnostics, BuildResultFlags.DeclarationEmitErrors, "Declaration file"), buildResult = _a.buildResult, step = _a.step);
92181                 return {
92182                     emitSkipped: true,
92183                     diagnostics: emitResult.diagnostics
92184                 };
92185             }
92186             var host = state.host, compilerHost = state.compilerHost;
92187             var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
92188             var newestDeclarationFileContentChangedTime = minimumDate;
92189             var anyDtsChanged = false;
92190             var emitterDiagnostics = ts.createDiagnosticCollection();
92191             var emittedOutputs = new ts.Map();
92192             outputFiles.forEach(function (_a) {
92193                 var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
92194                 var priorChangeTime;
92195                 if (!anyDtsChanged && isDeclarationFile(name)) {
92196                     if (host.fileExists(name) && state.readFileWithCache(name) === text) {
92197                         priorChangeTime = host.getModifiedTime(name);
92198                     }
92199                     else {
92200                         resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
92201                         anyDtsChanged = true;
92202                     }
92203                 }
92204                 emittedOutputs.set(toPath(state, name), name);
92205                 ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
92206                 if (priorChangeTime !== undefined) {
92207                     newestDeclarationFileContentChangedTime = newer(priorChangeTime, newestDeclarationFileContentChangedTime);
92208                 }
92209             });
92210             finishEmit(emitterDiagnostics, emittedOutputs, newestDeclarationFileContentChangedTime, anyDtsChanged, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
92211             return emitResult;
92212         }
92213         function emitBuildInfo(writeFileCallback, cancellationToken) {
92214             ts.Debug.assertIsDefined(program);
92215             ts.Debug.assert(step === BuildStep.EmitBuildInfo);
92216             var emitResult = program.emitBuildInfo(writeFileCallback, cancellationToken);
92217             if (emitResult.diagnostics.length) {
92218                 reportErrors(state, emitResult.diagnostics);
92219                 state.diagnostics.set(projectPath, __spreadArrays(state.diagnostics.get(projectPath), emitResult.diagnostics));
92220                 buildResult = BuildResultFlags.EmitErrors & buildResult;
92221             }
92222             if (emitResult.emittedFiles && state.writeFileName) {
92223                 emitResult.emittedFiles.forEach(function (name) { return listEmittedFile(state, config, name); });
92224             }
92225             afterProgramDone(state, program, config);
92226             step = BuildStep.QueueReferencingProjects;
92227             return emitResult;
92228         }
92229         function finishEmit(emitterDiagnostics, emittedOutputs, priorNewestUpdateTime, newestDeclarationFileContentChangedTimeIsMaximumDate, oldestOutputFileName, resultFlags) {
92230             var _a;
92231             var emitDiagnostics = emitterDiagnostics.getDiagnostics();
92232             if (emitDiagnostics.length) {
92233                 (_a = buildErrors(state, projectPath, program, config, emitDiagnostics, BuildResultFlags.EmitErrors, "Emit"), buildResult = _a.buildResult, step = _a.step);
92234                 return emitDiagnostics;
92235             }
92236             if (state.writeFileName) {
92237                 emittedOutputs.forEach(function (name) { return listEmittedFile(state, config, name); });
92238             }
92239             var newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(state, config, priorNewestUpdateTime, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
92240             state.diagnostics.delete(projectPath);
92241             state.projectStatus.set(projectPath, {
92242                 type: ts.UpToDateStatusType.UpToDate,
92243                 newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTimeIsMaximumDate ?
92244                     maximumDate :
92245                     newestDeclarationFileContentChangedTime,
92246                 oldestOutputFileName: oldestOutputFileName
92247             });
92248             afterProgramDone(state, program, config);
92249             step = BuildStep.QueueReferencingProjects;
92250             buildResult = resultFlags;
92251             return emitDiagnostics;
92252         }
92253         function emitBundle(writeFileCallback, customTransformers) {
92254             ts.Debug.assert(kind === InvalidatedProjectKind.UpdateBundle);
92255             if (state.options.dry) {
92256                 reportStatus(state, ts.Diagnostics.A_non_dry_build_would_update_output_of_project_0, project);
92257                 buildResult = BuildResultFlags.Success;
92258                 step = BuildStep.QueueReferencingProjects;
92259                 return undefined;
92260             }
92261             if (state.options.verbose)
92262                 reportStatus(state, ts.Diagnostics.Updating_output_of_project_0, project);
92263             var compilerHost = state.compilerHost;
92264             state.projectCompilerOptions = config.options;
92265             var outputFiles = ts.emitUsingBuildInfo(config, compilerHost, function (ref) {
92266                 var refName = resolveProjectName(state, ref.path);
92267                 return parseConfigFile(state, refName, toResolvedConfigFilePath(state, refName));
92268             }, customTransformers);
92269             if (ts.isString(outputFiles)) {
92270                 reportStatus(state, ts.Diagnostics.Cannot_update_output_of_project_0_because_there_was_error_reading_file_1, project, relName(state, outputFiles));
92271                 step = BuildStep.BuildInvalidatedProjectOfBundle;
92272                 return invalidatedProjectOfBundle = createBuildOrUpdateInvalidedProject(InvalidatedProjectKind.Build, state, project, projectPath, projectIndex, config, buildOrder);
92273             }
92274             ts.Debug.assert(!!outputFiles.length);
92275             var emitterDiagnostics = ts.createDiagnosticCollection();
92276             var emittedOutputs = new ts.Map();
92277             outputFiles.forEach(function (_a) {
92278                 var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
92279                 emittedOutputs.set(toPath(state, name), name);
92280                 ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
92281             });
92282             var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, minimumDate, false, outputFiles[0].name, BuildResultFlags.DeclarationOutputUnchanged);
92283             return { emitSkipped: false, diagnostics: emitDiagnostics };
92284         }
92285         function executeSteps(till, cancellationToken, writeFile, customTransformers) {
92286             while (step <= till && step < BuildStep.Done) {
92287                 var currentStep = step;
92288                 switch (step) {
92289                     case BuildStep.CreateProgram:
92290                         createProgram();
92291                         break;
92292                     case BuildStep.SyntaxDiagnostics:
92293                         getSyntaxDiagnostics(cancellationToken);
92294                         break;
92295                     case BuildStep.SemanticDiagnostics:
92296                         getSemanticDiagnostics(cancellationToken);
92297                         break;
92298                     case BuildStep.Emit:
92299                         emit(writeFile, cancellationToken, customTransformers);
92300                         break;
92301                     case BuildStep.EmitBuildInfo:
92302                         emitBuildInfo(writeFile, cancellationToken);
92303                         break;
92304                     case BuildStep.EmitBundle:
92305                         emitBundle(writeFile, customTransformers);
92306                         break;
92307                     case BuildStep.BuildInvalidatedProjectOfBundle:
92308                         ts.Debug.checkDefined(invalidatedProjectOfBundle).done(cancellationToken);
92309                         step = BuildStep.Done;
92310                         break;
92311                     case BuildStep.QueueReferencingProjects:
92312                         queueReferencingProjects(state, project, projectPath, projectIndex, config, buildOrder, ts.Debug.checkDefined(buildResult));
92313                         step++;
92314                         break;
92315                     case BuildStep.Done:
92316                     default:
92317                         ts.assertType(step);
92318                 }
92319                 ts.Debug.assert(step > currentStep);
92320             }
92321         }
92322     }
92323     function needsBuild(_a, status, config) {
92324         var options = _a.options;
92325         if (status.type !== ts.UpToDateStatusType.OutOfDateWithPrepend || options.force)
92326             return true;
92327         return config.fileNames.length === 0 ||
92328             !!ts.getConfigFileParsingDiagnostics(config).length ||
92329             !ts.isIncrementalCompilation(config.options);
92330     }
92331     function getNextInvalidatedProject(state, buildOrder, reportQueue) {
92332         if (!state.projectPendingBuild.size)
92333             return undefined;
92334         if (isCircularBuildOrder(buildOrder))
92335             return undefined;
92336         if (state.currentInvalidatedProject) {
92337             return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ?
92338                 state.currentInvalidatedProject :
92339                 undefined;
92340         }
92341         var options = state.options, projectPendingBuild = state.projectPendingBuild;
92342         for (var projectIndex = 0; projectIndex < buildOrder.length; projectIndex++) {
92343             var project = buildOrder[projectIndex];
92344             var projectPath = toResolvedConfigFilePath(state, project);
92345             var reloadLevel = state.projectPendingBuild.get(projectPath);
92346             if (reloadLevel === undefined)
92347                 continue;
92348             if (reportQueue) {
92349                 reportQueue = false;
92350                 reportBuildQueue(state, buildOrder);
92351             }
92352             var config = parseConfigFile(state, project, projectPath);
92353             if (!config) {
92354                 reportParseConfigFileDiagnostic(state, projectPath);
92355                 projectPendingBuild.delete(projectPath);
92356                 continue;
92357             }
92358             if (reloadLevel === ts.ConfigFileProgramReloadLevel.Full) {
92359                 watchConfigFile(state, project, projectPath, config);
92360                 watchWildCardDirectories(state, project, projectPath, config);
92361                 watchInputFiles(state, project, projectPath, config);
92362             }
92363             else if (reloadLevel === ts.ConfigFileProgramReloadLevel.Partial) {
92364                 var result = ts.getFileNamesFromConfigSpecs(config.configFileSpecs, ts.getDirectoryPath(project), config.options, state.parseConfigFileHost);
92365                 ts.updateErrorForNoInputFiles(result, project, config.configFileSpecs, config.errors, ts.canJsonReportNoInputFiles(config.raw));
92366                 config.fileNames = result.fileNames;
92367                 watchInputFiles(state, project, projectPath, config);
92368             }
92369             var status = getUpToDateStatus(state, config, projectPath);
92370             verboseReportProjectStatus(state, project, status);
92371             if (!options.force) {
92372                 if (status.type === ts.UpToDateStatusType.UpToDate) {
92373                     reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
92374                     projectPendingBuild.delete(projectPath);
92375                     if (options.dry) {
92376                         reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date, project);
92377                     }
92378                     continue;
92379                 }
92380                 if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes) {
92381                     reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
92382                     return createUpdateOutputFileStampsProject(state, project, projectPath, config, buildOrder);
92383                 }
92384             }
92385             if (status.type === ts.UpToDateStatusType.UpstreamBlocked) {
92386                 reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
92387                 projectPendingBuild.delete(projectPath);
92388                 if (options.verbose) {
92389                     reportStatus(state, status.upstreamProjectBlocked ?
92390                         ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built :
92391                         ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName);
92392                 }
92393                 continue;
92394             }
92395             if (status.type === ts.UpToDateStatusType.ContainerOnly) {
92396                 reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
92397                 projectPendingBuild.delete(projectPath);
92398                 continue;
92399             }
92400             return createBuildOrUpdateInvalidedProject(needsBuild(state, status, config) ?
92401                 InvalidatedProjectKind.Build :
92402                 InvalidatedProjectKind.UpdateBundle, state, project, projectPath, projectIndex, config, buildOrder);
92403         }
92404         return undefined;
92405     }
92406     function listEmittedFile(_a, proj, file) {
92407         var writeFileName = _a.writeFileName;
92408         if (writeFileName && proj.options.listEmittedFiles) {
92409             writeFileName("TSFILE: " + file);
92410         }
92411     }
92412     function getOldProgram(_a, proj, parsed) {
92413         var options = _a.options, builderPrograms = _a.builderPrograms, compilerHost = _a.compilerHost;
92414         if (options.force)
92415             return undefined;
92416         var value = builderPrograms.get(proj);
92417         if (value)
92418             return value;
92419         return ts.readBuilderProgram(parsed.options, compilerHost);
92420     }
92421     function afterProgramDone(state, program, config) {
92422         if (program) {
92423             if (program && state.writeFileName)
92424                 ts.listFiles(program, state.writeFileName);
92425             if (state.host.afterProgramEmitAndDiagnostics) {
92426                 state.host.afterProgramEmitAndDiagnostics(program);
92427             }
92428             program.releaseProgram();
92429         }
92430         else if (state.host.afterEmitBundle) {
92431             state.host.afterEmitBundle(config);
92432         }
92433         state.projectCompilerOptions = state.baseCompilerOptions;
92434     }
92435     function buildErrors(state, resolvedPath, program, config, diagnostics, buildResult, errorType) {
92436         var canEmitBuildInfo = !(buildResult & BuildResultFlags.SyntaxErrors) && program && !ts.outFile(program.getCompilerOptions());
92437         reportAndStoreErrors(state, resolvedPath, diagnostics);
92438         state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" });
92439         if (canEmitBuildInfo)
92440             return { buildResult: buildResult, step: BuildStep.EmitBuildInfo };
92441         afterProgramDone(state, program, config);
92442         return { buildResult: buildResult, step: BuildStep.QueueReferencingProjects };
92443     }
92444     function updateModuleResolutionCache(state, proj, config) {
92445         if (!state.moduleResolutionCache)
92446             return;
92447         var moduleResolutionCache = state.moduleResolutionCache;
92448         var projPath = toPath(state, proj);
92449         if (moduleResolutionCache.directoryToModuleNameMap.redirectsMap.size === 0) {
92450             ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size === 0);
92451             moduleResolutionCache.directoryToModuleNameMap.redirectsMap.set(projPath, moduleResolutionCache.directoryToModuleNameMap.ownMap);
92452             moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.set(projPath, moduleResolutionCache.moduleNameToDirectoryMap.ownMap);
92453         }
92454         else {
92455             ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size > 0);
92456             var ref = {
92457                 sourceFile: config.options.configFile,
92458                 commandLine: config
92459             };
92460             moduleResolutionCache.directoryToModuleNameMap.setOwnMap(moduleResolutionCache.directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref));
92461             moduleResolutionCache.moduleNameToDirectoryMap.setOwnMap(moduleResolutionCache.moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref));
92462         }
92463         moduleResolutionCache.directoryToModuleNameMap.setOwnOptions(config.options);
92464         moduleResolutionCache.moduleNameToDirectoryMap.setOwnOptions(config.options);
92465     }
92466     function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName) {
92467         var tsconfigTime = state.host.getModifiedTime(configFile) || ts.missingFileModifiedTime;
92468         if (oldestOutputFileTime < tsconfigTime) {
92469             return {
92470                 type: ts.UpToDateStatusType.OutOfDateWithSelf,
92471                 outOfDateOutputFileName: oldestOutputFileName,
92472                 newerInputFileName: configFile
92473             };
92474         }
92475     }
92476     function getUpToDateStatusWorker(state, project, resolvedPath) {
92477         var newestInputFileName = undefined;
92478         var newestInputFileTime = minimumDate;
92479         var host = state.host;
92480         for (var _i = 0, _a = project.fileNames; _i < _a.length; _i++) {
92481             var inputFile = _a[_i];
92482             if (!host.fileExists(inputFile)) {
92483                 return {
92484                     type: ts.UpToDateStatusType.Unbuildable,
92485                     reason: inputFile + " does not exist"
92486                 };
92487             }
92488             var inputTime = host.getModifiedTime(inputFile) || ts.missingFileModifiedTime;
92489             if (inputTime > newestInputFileTime) {
92490                 newestInputFileName = inputFile;
92491                 newestInputFileTime = inputTime;
92492             }
92493         }
92494         if (!project.fileNames.length && !ts.canJsonReportNoInputFiles(project.raw)) {
92495             return {
92496                 type: ts.UpToDateStatusType.ContainerOnly
92497             };
92498         }
92499         var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
92500         var oldestOutputFileName = "(none)";
92501         var oldestOutputFileTime = maximumDate;
92502         var newestOutputFileName = "(none)";
92503         var newestOutputFileTime = minimumDate;
92504         var missingOutputFileName;
92505         var newestDeclarationFileContentChangedTime = minimumDate;
92506         var isOutOfDateWithInputs = false;
92507         for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) {
92508             var output = outputs_1[_b];
92509             if (!host.fileExists(output)) {
92510                 missingOutputFileName = output;
92511                 break;
92512             }
92513             var outputTime = host.getModifiedTime(output) || ts.missingFileModifiedTime;
92514             if (outputTime < oldestOutputFileTime) {
92515                 oldestOutputFileTime = outputTime;
92516                 oldestOutputFileName = output;
92517             }
92518             if (outputTime < newestInputFileTime) {
92519                 isOutOfDateWithInputs = true;
92520                 break;
92521             }
92522             if (outputTime > newestOutputFileTime) {
92523                 newestOutputFileTime = outputTime;
92524                 newestOutputFileName = output;
92525             }
92526             if (isDeclarationFile(output)) {
92527                 var outputModifiedTime = host.getModifiedTime(output) || ts.missingFileModifiedTime;
92528                 newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
92529             }
92530         }
92531         var pseudoUpToDate = false;
92532         var usesPrepend = false;
92533         var upstreamChangedProject;
92534         if (project.projectReferences) {
92535             state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream });
92536             for (var _c = 0, _d = project.projectReferences; _c < _d.length; _c++) {
92537                 var ref = _d[_c];
92538                 usesPrepend = usesPrepend || !!(ref.prepend);
92539                 var resolvedRef = ts.resolveProjectReferencePath(ref);
92540                 var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef);
92541                 var refStatus = getUpToDateStatus(state, parseConfigFile(state, resolvedRef, resolvedRefPath), resolvedRefPath);
92542                 if (refStatus.type === ts.UpToDateStatusType.ComputingUpstream ||
92543                     refStatus.type === ts.UpToDateStatusType.ContainerOnly) {
92544                     continue;
92545                 }
92546                 if (refStatus.type === ts.UpToDateStatusType.Unbuildable ||
92547                     refStatus.type === ts.UpToDateStatusType.UpstreamBlocked) {
92548                     return {
92549                         type: ts.UpToDateStatusType.UpstreamBlocked,
92550                         upstreamProjectName: ref.path,
92551                         upstreamProjectBlocked: refStatus.type === ts.UpToDateStatusType.UpstreamBlocked
92552                     };
92553                 }
92554                 if (refStatus.type !== ts.UpToDateStatusType.UpToDate) {
92555                     return {
92556                         type: ts.UpToDateStatusType.UpstreamOutOfDate,
92557                         upstreamProjectName: ref.path
92558                     };
92559                 }
92560                 if (!missingOutputFileName) {
92561                     if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
92562                         continue;
92563                     }
92564                     if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
92565                         pseudoUpToDate = true;
92566                         upstreamChangedProject = ref.path;
92567                         continue;
92568                     }
92569                     ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here");
92570                     return {
92571                         type: ts.UpToDateStatusType.OutOfDateWithUpstream,
92572                         outOfDateOutputFileName: oldestOutputFileName,
92573                         newerProjectName: ref.path
92574                     };
92575                 }
92576             }
92577         }
92578         if (missingOutputFileName !== undefined) {
92579             return {
92580                 type: ts.UpToDateStatusType.OutputMissing,
92581                 missingOutputFileName: missingOutputFileName
92582             };
92583         }
92584         if (isOutOfDateWithInputs) {
92585             return {
92586                 type: ts.UpToDateStatusType.OutOfDateWithSelf,
92587                 outOfDateOutputFileName: oldestOutputFileName,
92588                 newerInputFileName: newestInputFileName
92589             };
92590         }
92591         else {
92592             var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
92593             if (configStatus)
92594                 return configStatus;
92595             var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
92596             if (extendedConfigStatus)
92597                 return extendedConfigStatus;
92598         }
92599         if (!state.buildInfoChecked.has(resolvedPath)) {
92600             state.buildInfoChecked.set(resolvedPath, true);
92601             var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
92602             if (buildInfoPath) {
92603                 var value = state.readFileWithCache(buildInfoPath);
92604                 var buildInfo = value && ts.getBuildInfo(value);
92605                 if (buildInfo && (buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
92606                     return {
92607                         type: ts.UpToDateStatusType.TsVersionOutputOfDate,
92608                         version: buildInfo.version
92609                     };
92610                 }
92611             }
92612         }
92613         if (usesPrepend && pseudoUpToDate) {
92614             return {
92615                 type: ts.UpToDateStatusType.OutOfDateWithPrepend,
92616                 outOfDateOutputFileName: oldestOutputFileName,
92617                 newerProjectName: upstreamChangedProject
92618             };
92619         }
92620         return {
92621             type: pseudoUpToDate ? ts.UpToDateStatusType.UpToDateWithUpstreamTypes : ts.UpToDateStatusType.UpToDate,
92622             newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime,
92623             newestInputFileTime: newestInputFileTime,
92624             newestOutputFileTime: newestOutputFileTime,
92625             newestInputFileName: newestInputFileName,
92626             newestOutputFileName: newestOutputFileName,
92627             oldestOutputFileName: oldestOutputFileName
92628         };
92629     }
92630     function getUpToDateStatus(state, project, resolvedPath) {
92631         if (project === undefined) {
92632             return { type: ts.UpToDateStatusType.Unbuildable, reason: "File deleted mid-build" };
92633         }
92634         var prior = state.projectStatus.get(resolvedPath);
92635         if (prior !== undefined) {
92636             return prior;
92637         }
92638         var actual = getUpToDateStatusWorker(state, project, resolvedPath);
92639         state.projectStatus.set(resolvedPath, actual);
92640         return actual;
92641     }
92642     function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) {
92643         var host = state.host;
92644         var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
92645         if (!skipOutputs || outputs.length !== skipOutputs.size) {
92646             var reportVerbose = !!state.options.verbose;
92647             var now = host.now ? host.now() : new Date();
92648             for (var _i = 0, outputs_2 = outputs; _i < outputs_2.length; _i++) {
92649                 var file = outputs_2[_i];
92650                 if (skipOutputs && skipOutputs.has(toPath(state, file))) {
92651                     continue;
92652                 }
92653                 if (reportVerbose) {
92654                     reportVerbose = false;
92655                     reportStatus(state, verboseMessage, proj.options.configFilePath);
92656                 }
92657                 if (isDeclarationFile(file)) {
92658                     priorNewestUpdateTime = newer(priorNewestUpdateTime, host.getModifiedTime(file) || ts.missingFileModifiedTime);
92659                 }
92660                 host.setModifiedTime(file, now);
92661             }
92662         }
92663         return priorNewestUpdateTime;
92664     }
92665     function updateOutputTimestamps(state, proj, resolvedPath) {
92666         if (state.options.dry) {
92667             return reportStatus(state, ts.Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath);
92668         }
92669         var priorNewestUpdateTime = updateOutputTimestampsWorker(state, proj, minimumDate, ts.Diagnostics.Updating_output_timestamps_of_project_0);
92670         state.projectStatus.set(resolvedPath, {
92671             type: ts.UpToDateStatusType.UpToDate,
92672             newestDeclarationFileContentChangedTime: priorNewestUpdateTime,
92673             oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames())
92674         });
92675     }
92676     function queueReferencingProjects(state, project, projectPath, projectIndex, config, buildOrder, buildResult) {
92677         if (buildResult & BuildResultFlags.AnyErrors)
92678             return;
92679         if (!config.options.composite)
92680             return;
92681         for (var index = projectIndex + 1; index < buildOrder.length; index++) {
92682             var nextProject = buildOrder[index];
92683             var nextProjectPath = toResolvedConfigFilePath(state, nextProject);
92684             if (state.projectPendingBuild.has(nextProjectPath))
92685                 continue;
92686             var nextProjectConfig = parseConfigFile(state, nextProject, nextProjectPath);
92687             if (!nextProjectConfig || !nextProjectConfig.projectReferences)
92688                 continue;
92689             for (var _i = 0, _a = nextProjectConfig.projectReferences; _i < _a.length; _i++) {
92690                 var ref = _a[_i];
92691                 var resolvedRefPath = resolveProjectName(state, ref.path);
92692                 if (toResolvedConfigFilePath(state, resolvedRefPath) !== projectPath)
92693                     continue;
92694                 var status = state.projectStatus.get(nextProjectPath);
92695                 if (status) {
92696                     switch (status.type) {
92697                         case ts.UpToDateStatusType.UpToDate:
92698                             if (buildResult & BuildResultFlags.DeclarationOutputUnchanged) {
92699                                 if (ref.prepend) {
92700                                     state.projectStatus.set(nextProjectPath, {
92701                                         type: ts.UpToDateStatusType.OutOfDateWithPrepend,
92702                                         outOfDateOutputFileName: status.oldestOutputFileName,
92703                                         newerProjectName: project
92704                                     });
92705                                 }
92706                                 else {
92707                                     status.type = ts.UpToDateStatusType.UpToDateWithUpstreamTypes;
92708                                 }
92709                                 break;
92710                             }
92711                         case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
92712                         case ts.UpToDateStatusType.OutOfDateWithPrepend:
92713                             if (!(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) {
92714                                 state.projectStatus.set(nextProjectPath, {
92715                                     type: ts.UpToDateStatusType.OutOfDateWithUpstream,
92716                                     outOfDateOutputFileName: status.type === ts.UpToDateStatusType.OutOfDateWithPrepend ? status.outOfDateOutputFileName : status.oldestOutputFileName,
92717                                     newerProjectName: project
92718                                 });
92719                             }
92720                             break;
92721                         case ts.UpToDateStatusType.UpstreamBlocked:
92722                             if (toResolvedConfigFilePath(state, resolveProjectName(state, status.upstreamProjectName)) === projectPath) {
92723                                 clearProjectStatus(state, nextProjectPath);
92724                             }
92725                             break;
92726                     }
92727                 }
92728                 addProjToQueue(state, nextProjectPath, ts.ConfigFileProgramReloadLevel.None);
92729                 break;
92730             }
92731         }
92732     }
92733     function build(state, project, cancellationToken, onlyReferences) {
92734         var buildOrder = getBuildOrderFor(state, project, onlyReferences);
92735         if (!buildOrder)
92736             return ts.ExitStatus.InvalidProject_OutputsSkipped;
92737         setupInitialBuild(state, cancellationToken);
92738         var reportQueue = true;
92739         var successfulProjects = 0;
92740         while (true) {
92741             var invalidatedProject = getNextInvalidatedProject(state, buildOrder, reportQueue);
92742             if (!invalidatedProject)
92743                 break;
92744             reportQueue = false;
92745             invalidatedProject.done(cancellationToken);
92746             if (!state.diagnostics.has(invalidatedProject.projectPath))
92747                 successfulProjects++;
92748         }
92749         disableCache(state);
92750         reportErrorSummary(state, buildOrder);
92751         startWatching(state, buildOrder);
92752         return isCircularBuildOrder(buildOrder)
92753             ? ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped
92754             : !buildOrder.some(function (p) { return state.diagnostics.has(toResolvedConfigFilePath(state, p)); })
92755                 ? ts.ExitStatus.Success
92756                 : successfulProjects
92757                     ? ts.ExitStatus.DiagnosticsPresent_OutputsGenerated
92758                     : ts.ExitStatus.DiagnosticsPresent_OutputsSkipped;
92759     }
92760     function clean(state, project, onlyReferences) {
92761         var buildOrder = getBuildOrderFor(state, project, onlyReferences);
92762         if (!buildOrder)
92763             return ts.ExitStatus.InvalidProject_OutputsSkipped;
92764         if (isCircularBuildOrder(buildOrder)) {
92765             reportErrors(state, buildOrder.circularDiagnostics);
92766             return ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped;
92767         }
92768         var options = state.options, host = state.host;
92769         var filesToDelete = options.dry ? [] : undefined;
92770         for (var _i = 0, buildOrder_1 = buildOrder; _i < buildOrder_1.length; _i++) {
92771             var proj = buildOrder_1[_i];
92772             var resolvedPath = toResolvedConfigFilePath(state, proj);
92773             var parsed = parseConfigFile(state, proj, resolvedPath);
92774             if (parsed === undefined) {
92775                 reportParseConfigFileDiagnostic(state, resolvedPath);
92776                 continue;
92777             }
92778             var outputs = ts.getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames());
92779             for (var _a = 0, outputs_3 = outputs; _a < outputs_3.length; _a++) {
92780                 var output = outputs_3[_a];
92781                 if (host.fileExists(output)) {
92782                     if (filesToDelete) {
92783                         filesToDelete.push(output);
92784                     }
92785                     else {
92786                         host.deleteFile(output);
92787                         invalidateProject(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None);
92788                     }
92789                 }
92790             }
92791         }
92792         if (filesToDelete) {
92793             reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * " + f; }).join(""));
92794         }
92795         return ts.ExitStatus.Success;
92796     }
92797     function invalidateProject(state, resolved, reloadLevel) {
92798         if (state.host.getParsedCommandLine && reloadLevel === ts.ConfigFileProgramReloadLevel.Partial) {
92799             reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
92800         }
92801         if (reloadLevel === ts.ConfigFileProgramReloadLevel.Full) {
92802             state.configFileCache.delete(resolved);
92803             state.buildOrder = undefined;
92804         }
92805         state.needsSummary = true;
92806         clearProjectStatus(state, resolved);
92807         addProjToQueue(state, resolved, reloadLevel);
92808         enableCache(state);
92809     }
92810     function invalidateProjectAndScheduleBuilds(state, resolvedPath, reloadLevel) {
92811         state.reportFileChangeDetected = true;
92812         invalidateProject(state, resolvedPath, reloadLevel);
92813         scheduleBuildInvalidatedProject(state);
92814     }
92815     function scheduleBuildInvalidatedProject(state) {
92816         var hostWithWatch = state.hostWithWatch;
92817         if (!hostWithWatch.setTimeout || !hostWithWatch.clearTimeout) {
92818             return;
92819         }
92820         if (state.timerToBuildInvalidatedProject) {
92821             hostWithWatch.clearTimeout(state.timerToBuildInvalidatedProject);
92822         }
92823         state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject, 250, state);
92824     }
92825     function buildNextInvalidatedProject(state) {
92826         state.timerToBuildInvalidatedProject = undefined;
92827         if (state.reportFileChangeDetected) {
92828             state.reportFileChangeDetected = false;
92829             state.projectErrorsReported.clear();
92830             reportWatchStatus(state, ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
92831         }
92832         var buildOrder = getBuildOrder(state);
92833         var invalidatedProject = getNextInvalidatedProject(state, buildOrder, false);
92834         if (invalidatedProject) {
92835             invalidatedProject.done();
92836             if (state.projectPendingBuild.size) {
92837                 if (state.watch && !state.timerToBuildInvalidatedProject) {
92838                     scheduleBuildInvalidatedProject(state);
92839                 }
92840                 return;
92841             }
92842         }
92843         disableCache(state);
92844         reportErrorSummary(state, buildOrder);
92845     }
92846     function watchConfigFile(state, resolved, resolvedPath, parsed) {
92847         if (!state.watch || state.allWatchedConfigFiles.has(resolvedPath))
92848             return;
92849         state.allWatchedConfigFiles.set(resolvedPath, state.watchFile(state.hostWithWatch, resolved, function () {
92850             invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full);
92851         }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.ConfigFile, resolved));
92852     }
92853     function watchWildCardDirectories(state, resolved, resolvedPath, parsed) {
92854         if (!state.watch)
92855             return;
92856         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) {
92857             if (ts.isIgnoredFileFromWildCardWatching({
92858                 watchedDirPath: toPath(state, dir),
92859                 fileOrDirectory: fileOrDirectory,
92860                 fileOrDirectoryPath: toPath(state, fileOrDirectory),
92861                 configFileName: resolved,
92862                 configFileSpecs: parsed.configFileSpecs,
92863                 currentDirectory: state.currentDirectory,
92864                 options: parsed.options,
92865                 program: state.builderPrograms.get(resolvedPath),
92866                 useCaseSensitiveFileNames: state.parseConfigFileHost.useCaseSensitiveFileNames,
92867                 writeLog: function (s) { return state.writeLog(s); }
92868             }))
92869                 return;
92870             invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Partial);
92871         }, flags, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.WildcardDirectory, resolved); });
92872     }
92873     function watchInputFiles(state, resolved, resolvedPath, parsed) {
92874         if (!state.watch)
92875             return;
92876         ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedInputFiles, resolvedPath), ts.arrayToMap(parsed.fileNames, function (fileName) { return toPath(state, fileName); }), {
92877             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); },
92878             onDeleteValue: ts.closeFileWatcher,
92879         });
92880     }
92881     function startWatching(state, buildOrder) {
92882         if (!state.watchAllProjectsPending)
92883             return;
92884         state.watchAllProjectsPending = false;
92885         for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) {
92886             var resolved = _a[_i];
92887             var resolvedPath = toResolvedConfigFilePath(state, resolved);
92888             var cfg = parseConfigFile(state, resolved, resolvedPath);
92889             watchConfigFile(state, resolved, resolvedPath, cfg);
92890             if (cfg) {
92891                 watchWildCardDirectories(state, resolved, resolvedPath, cfg);
92892                 watchInputFiles(state, resolved, resolvedPath, cfg);
92893             }
92894         }
92895     }
92896     function stopWatching(state) {
92897         ts.clearMap(state.allWatchedConfigFiles, ts.closeFileWatcher);
92898         ts.clearMap(state.allWatchedWildcardDirectories, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf); });
92899         ts.clearMap(state.allWatchedInputFiles, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcher); });
92900     }
92901     function createSolutionBuilderWorker(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions) {
92902         var state = createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions);
92903         return {
92904             build: function (project, cancellationToken) { return build(state, project, cancellationToken); },
92905             clean: function (project) { return clean(state, project); },
92906             buildReferences: function (project, cancellationToken) { return build(state, project, cancellationToken, true); },
92907             cleanReferences: function (project) { return clean(state, project, true); },
92908             getNextInvalidatedProject: function (cancellationToken) {
92909                 setupInitialBuild(state, cancellationToken);
92910                 return getNextInvalidatedProject(state, getBuildOrder(state), false);
92911             },
92912             getBuildOrder: function () { return getBuildOrder(state); },
92913             getUpToDateStatusOfProject: function (project) {
92914                 var configFileName = resolveProjectName(state, project);
92915                 var configFilePath = toResolvedConfigFilePath(state, configFileName);
92916                 return getUpToDateStatus(state, parseConfigFile(state, configFileName, configFilePath), configFilePath);
92917             },
92918             invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); },
92919             buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); },
92920             getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); },
92921             close: function () { return stopWatching(state); },
92922         };
92923     }
92924     function relName(state, path) {
92925         return ts.convertToRelativePath(path, state.currentDirectory, function (f) { return state.getCanonicalFileName(f); });
92926     }
92927     function reportStatus(state, message) {
92928         var args = [];
92929         for (var _i = 2; _i < arguments.length; _i++) {
92930             args[_i - 2] = arguments[_i];
92931         }
92932         state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)));
92933     }
92934     function reportWatchStatus(state, message) {
92935         var args = [];
92936         for (var _i = 2; _i < arguments.length; _i++) {
92937             args[_i - 2] = arguments[_i];
92938         }
92939         if (state.hostWithWatch.onWatchStatusChange) {
92940             state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)), state.host.getNewLine(), state.baseCompilerOptions);
92941         }
92942     }
92943     function reportErrors(_a, errors) {
92944         var host = _a.host;
92945         errors.forEach(function (err) { return host.reportDiagnostic(err); });
92946     }
92947     function reportAndStoreErrors(state, proj, errors) {
92948         reportErrors(state, errors);
92949         state.projectErrorsReported.set(proj, true);
92950         if (errors.length) {
92951             state.diagnostics.set(proj, errors);
92952         }
92953     }
92954     function reportParseConfigFileDiagnostic(state, proj) {
92955         reportAndStoreErrors(state, proj, [state.configFileCache.get(proj)]);
92956     }
92957     function reportErrorSummary(state, buildOrder) {
92958         if (!state.needsSummary)
92959             return;
92960         state.needsSummary = false;
92961         var canReportSummary = state.watch || !!state.host.reportErrorSummary;
92962         var diagnostics = state.diagnostics;
92963         var totalErrors = 0;
92964         if (isCircularBuildOrder(buildOrder)) {
92965             reportBuildQueue(state, buildOrder.buildOrder);
92966             reportErrors(state, buildOrder.circularDiagnostics);
92967             if (canReportSummary)
92968                 totalErrors += ts.getErrorCountForSummary(buildOrder.circularDiagnostics);
92969         }
92970         else {
92971             buildOrder.forEach(function (project) {
92972                 var projectPath = toResolvedConfigFilePath(state, project);
92973                 if (!state.projectErrorsReported.has(projectPath)) {
92974                     reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray);
92975                 }
92976             });
92977             if (canReportSummary)
92978                 diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); });
92979         }
92980         if (state.watch) {
92981             reportWatchStatus(state, ts.getWatchErrorSummaryDiagnosticMessage(totalErrors), totalErrors);
92982         }
92983         else if (state.host.reportErrorSummary) {
92984             state.host.reportErrorSummary(totalErrors);
92985         }
92986     }
92987     function reportBuildQueue(state, buildQueue) {
92988         if (state.options.verbose) {
92989             reportStatus(state, ts.Diagnostics.Projects_in_this_build_Colon_0, buildQueue.map(function (s) { return "\r\n    * " + relName(state, s); }).join(""));
92990         }
92991     }
92992     function reportUpToDateStatus(state, configFileName, status) {
92993         switch (status.type) {
92994             case ts.UpToDateStatusType.OutOfDateWithSelf:
92995                 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));
92996             case ts.UpToDateStatusType.OutOfDateWithUpstream:
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.newerProjectName));
92998             case ts.UpToDateStatusType.OutputMissing:
92999                 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));
93000             case ts.UpToDateStatusType.UpToDate:
93001                 if (status.newestInputFileTime !== undefined) {
93002                     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 || ""));
93003                 }
93004                 break;
93005             case ts.UpToDateStatusType.OutOfDateWithPrepend:
93006                 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));
93007             case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
93008                 return reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, relName(state, configFileName));
93009             case ts.UpToDateStatusType.UpstreamOutOfDate:
93010                 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));
93011             case ts.UpToDateStatusType.UpstreamBlocked:
93012                 return reportStatus(state, status.upstreamProjectBlocked ?
93013                     ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built :
93014                     ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName));
93015             case ts.UpToDateStatusType.Unbuildable:
93016                 return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason);
93017             case ts.UpToDateStatusType.TsVersionOutputOfDate:
93018                 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);
93019             case ts.UpToDateStatusType.ContainerOnly:
93020             case ts.UpToDateStatusType.ComputingUpstream:
93021                 break;
93022             default:
93023                 ts.assertType(status);
93024         }
93025     }
93026     function verboseReportProjectStatus(state, configFileName, status) {
93027         if (state.options.verbose) {
93028             reportUpToDateStatus(state, configFileName, status);
93029         }
93030     }
93031 })(ts || (ts = {}));
93032 var ts;
93033 (function (ts) {
93034     function countLines(program) {
93035         var count = 0;
93036         ts.forEach(program.getSourceFiles(), function (file) {
93037             count += ts.getLineStarts(file).length;
93038         });
93039         return count;
93040     }
93041     function updateReportDiagnostic(sys, existing, options) {
93042         return shouldBePretty(sys, options) ?
93043             ts.createDiagnosticReporter(sys, true) :
93044             existing;
93045     }
93046     function defaultIsPretty(sys) {
93047         return !!sys.writeOutputIsTTY && sys.writeOutputIsTTY();
93048     }
93049     function shouldBePretty(sys, options) {
93050         if (!options || typeof options.pretty === "undefined") {
93051             return defaultIsPretty(sys);
93052         }
93053         return options.pretty;
93054     }
93055     function getOptionsForHelp(commandLine) {
93056         return !!commandLine.options.all ?
93057             ts.sort(ts.optionDeclarations, function (a, b) { return ts.compareStringsCaseInsensitive(a.name, b.name); }) :
93058             ts.filter(ts.optionDeclarations.slice(), function (v) { return !!v.showInSimplifiedHelpView; });
93059     }
93060     function printVersion(sys) {
93061         sys.write(ts.getDiagnosticText(ts.Diagnostics.Version_0, ts.version) + sys.newLine);
93062     }
93063     function printHelp(sys, optionsList, syntaxPrefix) {
93064         if (syntaxPrefix === void 0) { syntaxPrefix = ""; }
93065         var output = [];
93066         var syntaxLength = ts.getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, "").length;
93067         var examplesLength = ts.getDiagnosticText(ts.Diagnostics.Examples_Colon_0, "").length;
93068         var marginLength = Math.max(syntaxLength, examplesLength);
93069         var syntax = makePadding(marginLength - syntaxLength);
93070         syntax += "tsc " + syntaxPrefix + "[" + ts.getDiagnosticText(ts.Diagnostics.options) + "] [" + ts.getDiagnosticText(ts.Diagnostics.file) + "...]";
93071         output.push(ts.getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, syntax));
93072         output.push(sys.newLine + sys.newLine);
93073         var padding = makePadding(marginLength);
93074         output.push(ts.getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + sys.newLine);
93075         output.push(padding + "tsc --outFile file.js file.ts" + sys.newLine);
93076         output.push(padding + "tsc @args.txt" + sys.newLine);
93077         output.push(padding + "tsc --build tsconfig.json" + sys.newLine);
93078         output.push(sys.newLine);
93079         output.push(ts.getDiagnosticText(ts.Diagnostics.Options_Colon) + sys.newLine);
93080         marginLength = 0;
93081         var usageColumn = [];
93082         var descriptionColumn = [];
93083         var optionsDescriptionMap = new ts.Map();
93084         for (var _i = 0, optionsList_1 = optionsList; _i < optionsList_1.length; _i++) {
93085             var option = optionsList_1[_i];
93086             if (!option.description) {
93087                 continue;
93088             }
93089             var usageText_1 = " ";
93090             if (option.shortName) {
93091                 usageText_1 += "-" + option.shortName;
93092                 usageText_1 += getParamType(option);
93093                 usageText_1 += ", ";
93094             }
93095             usageText_1 += "--" + option.name;
93096             usageText_1 += getParamType(option);
93097             usageColumn.push(usageText_1);
93098             var description = void 0;
93099             if (option.name === "lib") {
93100                 description = ts.getDiagnosticText(option.description);
93101                 var element = option.element;
93102                 var typeMap = element.type;
93103                 optionsDescriptionMap.set(description, ts.arrayFrom(typeMap.keys()).map(function (key) { return "'" + key + "'"; }));
93104             }
93105             else {
93106                 description = ts.getDiagnosticText(option.description);
93107             }
93108             descriptionColumn.push(description);
93109             marginLength = Math.max(usageText_1.length, marginLength);
93110         }
93111         var usageText = " @<" + ts.getDiagnosticText(ts.Diagnostics.file) + ">";
93112         usageColumn.push(usageText);
93113         descriptionColumn.push(ts.getDiagnosticText(ts.Diagnostics.Insert_command_line_options_and_files_from_a_file));
93114         marginLength = Math.max(usageText.length, marginLength);
93115         for (var i = 0; i < usageColumn.length; i++) {
93116             var usage = usageColumn[i];
93117             var description = descriptionColumn[i];
93118             var kindsList = optionsDescriptionMap.get(description);
93119             output.push(usage + makePadding(marginLength - usage.length + 2) + description + sys.newLine);
93120             if (kindsList) {
93121                 output.push(makePadding(marginLength + 4));
93122                 for (var _a = 0, kindsList_1 = kindsList; _a < kindsList_1.length; _a++) {
93123                     var kind = kindsList_1[_a];
93124                     output.push(kind + " ");
93125                 }
93126                 output.push(sys.newLine);
93127             }
93128         }
93129         for (var _b = 0, output_1 = output; _b < output_1.length; _b++) {
93130             var line = output_1[_b];
93131             sys.write(line);
93132         }
93133         return;
93134         function getParamType(option) {
93135             if (option.paramType !== undefined) {
93136                 return " " + ts.getDiagnosticText(option.paramType);
93137             }
93138             return "";
93139         }
93140         function makePadding(paddingLength) {
93141             return Array(paddingLength + 1).join(" ");
93142         }
93143     }
93144     function executeCommandLineWorker(sys, cb, commandLine) {
93145         var reportDiagnostic = ts.createDiagnosticReporter(sys);
93146         if (commandLine.options.build) {
93147             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Option_build_must_be_the_first_command_line_argument));
93148             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
93149         }
93150         var configFileName;
93151         if (commandLine.options.locale) {
93152             ts.validateLocaleAndSetLanguage(commandLine.options.locale, sys, commandLine.errors);
93153         }
93154         if (commandLine.errors.length > 0) {
93155             commandLine.errors.forEach(reportDiagnostic);
93156             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
93157         }
93158         if (commandLine.options.init) {
93159             writeConfigFile(sys, reportDiagnostic, commandLine.options, commandLine.fileNames);
93160             return sys.exit(ts.ExitStatus.Success);
93161         }
93162         if (commandLine.options.version) {
93163             printVersion(sys);
93164             return sys.exit(ts.ExitStatus.Success);
93165         }
93166         if (commandLine.options.help || commandLine.options.all) {
93167             printVersion(sys);
93168             printHelp(sys, getOptionsForHelp(commandLine));
93169             return sys.exit(ts.ExitStatus.Success);
93170         }
93171         if (commandLine.options.watch && commandLine.options.listFilesOnly) {
93172             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "watch", "listFilesOnly"));
93173             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
93174         }
93175         if (commandLine.options.project) {
93176             if (commandLine.fileNames.length !== 0) {
93177                 reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line));
93178                 return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
93179             }
93180             var fileOrDirectory = ts.normalizePath(commandLine.options.project);
93181             if (!fileOrDirectory || sys.directoryExists(fileOrDirectory)) {
93182                 configFileName = ts.combinePaths(fileOrDirectory, "tsconfig.json");
93183                 if (!sys.fileExists(configFileName)) {
93184                     reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0, commandLine.options.project));
93185                     return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
93186                 }
93187             }
93188             else {
93189                 configFileName = fileOrDirectory;
93190                 if (!sys.fileExists(configFileName)) {
93191                     reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_specified_path_does_not_exist_Colon_0, commandLine.options.project));
93192                     return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
93193                 }
93194             }
93195         }
93196         else if (commandLine.fileNames.length === 0) {
93197             var searchPath = ts.normalizePath(sys.getCurrentDirectory());
93198             configFileName = ts.findConfigFile(searchPath, function (fileName) { return sys.fileExists(fileName); });
93199         }
93200         if (commandLine.fileNames.length === 0 && !configFileName) {
93201             if (commandLine.options.showConfig) {
93202                 reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_a_tsconfig_json_file_at_the_current_directory_Colon_0, ts.normalizePath(sys.getCurrentDirectory())));
93203             }
93204             else {
93205                 printVersion(sys);
93206                 printHelp(sys, getOptionsForHelp(commandLine));
93207             }
93208             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
93209         }
93210         var currentDirectory = sys.getCurrentDirectory();
93211         var commandLineOptions = ts.convertToOptionsWithAbsolutePaths(commandLine.options, function (fileName) { return ts.getNormalizedAbsolutePath(fileName, currentDirectory); });
93212         if (configFileName) {
93213             var configParseResult = ts.parseConfigFileWithSystem(configFileName, commandLineOptions, commandLine.watchOptions, sys, reportDiagnostic);
93214             if (commandLineOptions.showConfig) {
93215                 if (configParseResult.errors.length !== 0) {
93216                     reportDiagnostic = updateReportDiagnostic(sys, reportDiagnostic, configParseResult.options);
93217                     configParseResult.errors.forEach(reportDiagnostic);
93218                     return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
93219                 }
93220                 sys.write(JSON.stringify(ts.convertToTSConfig(configParseResult, configFileName, sys), null, 4) + sys.newLine);
93221                 return sys.exit(ts.ExitStatus.Success);
93222             }
93223             reportDiagnostic = updateReportDiagnostic(sys, reportDiagnostic, configParseResult.options);
93224             if (ts.isWatchSet(configParseResult.options)) {
93225                 if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic))
93226                     return;
93227                 return createWatchOfConfigFile(sys, cb, reportDiagnostic, configParseResult, commandLineOptions, commandLine.watchOptions);
93228             }
93229             else if (ts.isIncrementalCompilation(configParseResult.options)) {
93230                 performIncrementalCompilation(sys, cb, reportDiagnostic, configParseResult);
93231             }
93232             else {
93233                 performCompilation(sys, cb, reportDiagnostic, configParseResult);
93234             }
93235         }
93236         else {
93237             if (commandLineOptions.showConfig) {
93238                 sys.write(JSON.stringify(ts.convertToTSConfig(commandLine, ts.combinePaths(currentDirectory, "tsconfig.json"), sys), null, 4) + sys.newLine);
93239                 return sys.exit(ts.ExitStatus.Success);
93240             }
93241             reportDiagnostic = updateReportDiagnostic(sys, reportDiagnostic, commandLineOptions);
93242             if (ts.isWatchSet(commandLineOptions)) {
93243                 if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic))
93244                     return;
93245                 return createWatchOfFilesAndCompilerOptions(sys, cb, reportDiagnostic, commandLine.fileNames, commandLineOptions, commandLine.watchOptions);
93246             }
93247             else if (ts.isIncrementalCompilation(commandLineOptions)) {
93248                 performIncrementalCompilation(sys, cb, reportDiagnostic, __assign(__assign({}, commandLine), { options: commandLineOptions }));
93249             }
93250             else {
93251                 performCompilation(sys, cb, reportDiagnostic, __assign(__assign({}, commandLine), { options: commandLineOptions }));
93252             }
93253         }
93254     }
93255     function isBuild(commandLineArgs) {
93256         if (commandLineArgs.length > 0 && commandLineArgs[0].charCodeAt(0) === 45) {
93257             var firstOption = commandLineArgs[0].slice(commandLineArgs[0].charCodeAt(1) === 45 ? 2 : 1).toLowerCase();
93258             return firstOption === "build" || firstOption === "b";
93259         }
93260         return false;
93261     }
93262     ts.isBuild = isBuild;
93263     function executeCommandLine(system, cb, commandLineArgs) {
93264         if (isBuild(commandLineArgs)) {
93265             var _a = ts.parseBuildCommand(commandLineArgs.slice(1)), buildOptions_1 = _a.buildOptions, watchOptions_1 = _a.watchOptions, projects_1 = _a.projects, errors_1 = _a.errors;
93266             if (buildOptions_1.generateCpuProfile && system.enableCPUProfiler) {
93267                 system.enableCPUProfiler(buildOptions_1.generateCpuProfile, function () { return performBuild(system, cb, buildOptions_1, watchOptions_1, projects_1, errors_1); });
93268             }
93269             else {
93270                 return performBuild(system, cb, buildOptions_1, watchOptions_1, projects_1, errors_1);
93271             }
93272         }
93273         var commandLine = ts.parseCommandLine(commandLineArgs, function (path) { return system.readFile(path); });
93274         if (commandLine.options.generateCpuProfile && system.enableCPUProfiler) {
93275             system.enableCPUProfiler(commandLine.options.generateCpuProfile, function () { return executeCommandLineWorker(system, cb, commandLine); });
93276         }
93277         else {
93278             return executeCommandLineWorker(system, cb, commandLine);
93279         }
93280     }
93281     ts.executeCommandLine = executeCommandLine;
93282     function reportWatchModeWithoutSysSupport(sys, reportDiagnostic) {
93283         if (!sys.watchFile || !sys.watchDirectory) {
93284             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"));
93285             sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
93286             return true;
93287         }
93288         return false;
93289     }
93290     function performBuild(sys, cb, buildOptions, watchOptions, projects, errors) {
93291         var reportDiagnostic = updateReportDiagnostic(sys, ts.createDiagnosticReporter(sys), buildOptions);
93292         if (buildOptions.locale) {
93293             ts.validateLocaleAndSetLanguage(buildOptions.locale, sys, errors);
93294         }
93295         if (errors.length > 0) {
93296             errors.forEach(reportDiagnostic);
93297             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
93298         }
93299         if (buildOptions.help) {
93300             printVersion(sys);
93301             printHelp(sys, ts.buildOpts, "--build ");
93302             return sys.exit(ts.ExitStatus.Success);
93303         }
93304         if (projects.length === 0) {
93305             printVersion(sys);
93306             printHelp(sys, ts.buildOpts, "--build ");
93307             return sys.exit(ts.ExitStatus.Success);
93308         }
93309         if (!sys.getModifiedTime || !sys.setModifiedTime || (buildOptions.clean && !sys.deleteFile)) {
93310             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--build"));
93311             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
93312         }
93313         if (buildOptions.watch) {
93314             if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic))
93315                 return;
93316             var buildHost_1 = ts.createSolutionBuilderWithWatchHost(sys, undefined, reportDiagnostic, ts.createBuilderStatusReporter(sys, shouldBePretty(sys, buildOptions)), createWatchStatusReporter(sys, buildOptions));
93317             updateSolutionBuilderHost(sys, cb, buildHost_1);
93318             var builder_1 = ts.createSolutionBuilderWithWatch(buildHost_1, projects, buildOptions, watchOptions);
93319             builder_1.build();
93320             return builder_1;
93321         }
93322         var buildHost = ts.createSolutionBuilderHost(sys, undefined, reportDiagnostic, ts.createBuilderStatusReporter(sys, shouldBePretty(sys, buildOptions)), createReportErrorSummary(sys, buildOptions));
93323         updateSolutionBuilderHost(sys, cb, buildHost);
93324         var builder = ts.createSolutionBuilder(buildHost, projects, buildOptions);
93325         var exitStatus = buildOptions.clean ? builder.clean() : builder.build();
93326         ts.tracing.dumpLegend();
93327         return sys.exit(exitStatus);
93328     }
93329     function createReportErrorSummary(sys, options) {
93330         return shouldBePretty(sys, options) ?
93331             function (errorCount) { return sys.write(ts.getErrorSummaryText(errorCount, sys.newLine)); } :
93332             undefined;
93333     }
93334     function performCompilation(sys, cb, reportDiagnostic, config) {
93335         var fileNames = config.fileNames, options = config.options, projectReferences = config.projectReferences;
93336         var host = ts.createCompilerHostWorker(options, undefined, sys);
93337         var currentDirectory = host.getCurrentDirectory();
93338         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
93339         ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); });
93340         enableStatisticsAndTracing(sys, options, false);
93341         var programOptions = {
93342             rootNames: fileNames,
93343             options: options,
93344             projectReferences: projectReferences,
93345             host: host,
93346             configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics(config)
93347         };
93348         var program = ts.createProgram(programOptions);
93349         var exitStatus = ts.emitFilesAndReportErrorsAndGetExitStatus(program, reportDiagnostic, function (s) { return sys.write(s + sys.newLine); }, createReportErrorSummary(sys, options));
93350         reportStatistics(sys, program);
93351         cb(program);
93352         return sys.exit(exitStatus);
93353     }
93354     function performIncrementalCompilation(sys, cb, reportDiagnostic, config) {
93355         var options = config.options, fileNames = config.fileNames, projectReferences = config.projectReferences;
93356         enableStatisticsAndTracing(sys, options, false);
93357         var host = ts.createIncrementalCompilerHost(options, sys);
93358         var exitStatus = ts.performIncrementalCompilation({
93359             host: host,
93360             system: sys,
93361             rootNames: fileNames,
93362             options: options,
93363             configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics(config),
93364             projectReferences: projectReferences,
93365             reportDiagnostic: reportDiagnostic,
93366             reportErrorSummary: createReportErrorSummary(sys, options),
93367             afterProgramEmitAndDiagnostics: function (builderProgram) {
93368                 reportStatistics(sys, builderProgram.getProgram());
93369                 cb(builderProgram);
93370             }
93371         });
93372         return sys.exit(exitStatus);
93373     }
93374     function updateSolutionBuilderHost(sys, cb, buildHost) {
93375         updateCreateProgram(sys, buildHost);
93376         buildHost.afterProgramEmitAndDiagnostics = function (program) {
93377             reportStatistics(sys, program.getProgram());
93378             cb(program);
93379         };
93380         buildHost.afterEmitBundle = cb;
93381     }
93382     function updateCreateProgram(sys, host) {
93383         var compileUsingBuilder = host.createProgram;
93384         host.createProgram = function (rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences) {
93385             ts.Debug.assert(rootNames !== undefined || (options === undefined && !!oldProgram));
93386             if (options !== undefined) {
93387                 enableStatisticsAndTracing(sys, options, true);
93388             }
93389             return compileUsingBuilder(rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences);
93390         };
93391     }
93392     function updateWatchCompilationHost(sys, cb, watchCompilerHost) {
93393         updateCreateProgram(sys, watchCompilerHost);
93394         var emitFilesUsingBuilder = watchCompilerHost.afterProgramCreate;
93395         watchCompilerHost.afterProgramCreate = function (builderProgram) {
93396             emitFilesUsingBuilder(builderProgram);
93397             reportStatistics(sys, builderProgram.getProgram());
93398             cb(builderProgram);
93399         };
93400     }
93401     function createWatchStatusReporter(sys, options) {
93402         return ts.createWatchStatusReporter(sys, shouldBePretty(sys, options));
93403     }
93404     function createWatchOfConfigFile(system, cb, reportDiagnostic, configParseResult, optionsToExtend, watchOptionsToExtend) {
93405         var watchCompilerHost = ts.createWatchCompilerHostOfConfigFile({
93406             configFileName: configParseResult.options.configFilePath,
93407             optionsToExtend: optionsToExtend,
93408             watchOptionsToExtend: watchOptionsToExtend,
93409             system: system,
93410             reportDiagnostic: reportDiagnostic,
93411             reportWatchStatus: createWatchStatusReporter(system, configParseResult.options)
93412         });
93413         updateWatchCompilationHost(system, cb, watchCompilerHost);
93414         watchCompilerHost.configFileParsingResult = configParseResult;
93415         return ts.createWatchProgram(watchCompilerHost);
93416     }
93417     function createWatchOfFilesAndCompilerOptions(system, cb, reportDiagnostic, rootFiles, options, watchOptions) {
93418         var watchCompilerHost = ts.createWatchCompilerHostOfFilesAndCompilerOptions({
93419             rootFiles: rootFiles,
93420             options: options,
93421             watchOptions: watchOptions,
93422             system: system,
93423             reportDiagnostic: reportDiagnostic,
93424             reportWatchStatus: createWatchStatusReporter(system, options)
93425         });
93426         updateWatchCompilationHost(system, cb, watchCompilerHost);
93427         return ts.createWatchProgram(watchCompilerHost);
93428     }
93429     function canReportDiagnostics(system, compilerOptions) {
93430         return system === ts.sys && (compilerOptions.diagnostics || compilerOptions.extendedDiagnostics);
93431     }
93432     function canTrace(system, compilerOptions) {
93433         return system === ts.sys && compilerOptions.generateTrace;
93434     }
93435     function enableStatisticsAndTracing(system, compilerOptions, isBuildMode) {
93436         if (canReportDiagnostics(system, compilerOptions)) {
93437             ts.performance.enable();
93438         }
93439         if (canTrace(system, compilerOptions)) {
93440             ts.tracing.startTracing(compilerOptions.configFilePath, compilerOptions.generateTrace, isBuildMode);
93441         }
93442     }
93443     function reportStatistics(sys, program) {
93444         var compilerOptions = program.getCompilerOptions();
93445         if (canTrace(sys, compilerOptions)) {
93446             ts.tracing.stopTracing(program.getTypeCatalog());
93447         }
93448         var statistics;
93449         if (canReportDiagnostics(sys, compilerOptions)) {
93450             statistics = [];
93451             var memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1;
93452             reportCountStatistic("Files", program.getSourceFiles().length);
93453             reportCountStatistic("Lines", countLines(program));
93454             reportCountStatistic("Nodes", program.getNodeCount());
93455             reportCountStatistic("Identifiers", program.getIdentifierCount());
93456             reportCountStatistic("Symbols", program.getSymbolCount());
93457             reportCountStatistic("Types", program.getTypeCount());
93458             reportCountStatistic("Instantiations", program.getInstantiationCount());
93459             if (memoryUsed >= 0) {
93460                 reportStatisticalValue("Memory used", Math.round(memoryUsed / 1000) + "K");
93461             }
93462             var isPerformanceEnabled = ts.performance.isEnabled();
93463             var programTime = isPerformanceEnabled ? ts.performance.getDuration("Program") : 0;
93464             var bindTime = isPerformanceEnabled ? ts.performance.getDuration("Bind") : 0;
93465             var checkTime = isPerformanceEnabled ? ts.performance.getDuration("Check") : 0;
93466             var emitTime = isPerformanceEnabled ? ts.performance.getDuration("Emit") : 0;
93467             if (compilerOptions.extendedDiagnostics) {
93468                 var caches = program.getRelationCacheSizes();
93469                 reportCountStatistic("Assignability cache size", caches.assignable);
93470                 reportCountStatistic("Identity cache size", caches.identity);
93471                 reportCountStatistic("Subtype cache size", caches.subtype);
93472                 reportCountStatistic("Strict subtype cache size", caches.strictSubtype);
93473                 if (isPerformanceEnabled) {
93474                     ts.performance.forEachMeasure(function (name, duration) { return reportTimeStatistic(name + " time", duration); });
93475                 }
93476             }
93477             else if (isPerformanceEnabled) {
93478                 reportTimeStatistic("I/O read", ts.performance.getDuration("I/O Read"));
93479                 reportTimeStatistic("I/O write", ts.performance.getDuration("I/O Write"));
93480                 reportTimeStatistic("Parse time", programTime);
93481                 reportTimeStatistic("Bind time", bindTime);
93482                 reportTimeStatistic("Check time", checkTime);
93483                 reportTimeStatistic("Emit time", emitTime);
93484             }
93485             if (isPerformanceEnabled) {
93486                 reportTimeStatistic("Total time", programTime + bindTime + checkTime + emitTime);
93487             }
93488             reportStatistics();
93489             if (!isPerformanceEnabled) {
93490                 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");
93491             }
93492             else {
93493                 ts.performance.disable();
93494             }
93495         }
93496         function reportStatistics() {
93497             var nameSize = 0;
93498             var valueSize = 0;
93499             for (var _i = 0, statistics_1 = statistics; _i < statistics_1.length; _i++) {
93500                 var _a = statistics_1[_i], name = _a.name, value = _a.value;
93501                 if (name.length > nameSize) {
93502                     nameSize = name.length;
93503                 }
93504                 if (value.length > valueSize) {
93505                     valueSize = value.length;
93506                 }
93507             }
93508             for (var _b = 0, statistics_2 = statistics; _b < statistics_2.length; _b++) {
93509                 var _c = statistics_2[_b], name = _c.name, value = _c.value;
93510                 sys.write(ts.padRight(name + ":", nameSize + 2) + ts.padLeft(value.toString(), valueSize) + sys.newLine);
93511             }
93512         }
93513         function reportStatisticalValue(name, value) {
93514             statistics.push({ name: name, value: value });
93515         }
93516         function reportCountStatistic(name, count) {
93517             reportStatisticalValue(name, "" + count);
93518         }
93519         function reportTimeStatistic(name, time) {
93520             reportStatisticalValue(name, (time / 1000).toFixed(2) + "s");
93521         }
93522     }
93523     function writeConfigFile(sys, reportDiagnostic, options, fileNames) {
93524         var currentDirectory = sys.getCurrentDirectory();
93525         var file = ts.normalizePath(ts.combinePaths(currentDirectory, "tsconfig.json"));
93526         if (sys.fileExists(file)) {
93527             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file));
93528         }
93529         else {
93530             sys.writeFile(file, ts.generateTSConfig(options, fileNames, sys.newLine));
93531             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Successfully_created_a_tsconfig_json_file));
93532         }
93533         return;
93534     }
93535 })(ts || (ts = {}));
93536 // This file actually uses arguments passed on commandline and executes it
93537 ts.Debug.loggingHost = {
93538     log: function (_level, s) {
93539         ts.sys.write("" + (s || "") + ts.sys.newLine);
93540     }
93541 };
93542 if (ts.Debug.isDebugging) {
93543     ts.Debug.enableDebugInfo();
93544 }
93545 if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))) {
93546     ts.sys.tryEnableSourceMapsForHost();
93547 }
93548 if (ts.sys.setBlocking) {
93549     ts.sys.setBlocking();
93550 }
93551 ts.executeCommandLine(ts.sys, ts.noop, ts.sys.args);